Partager via


BackupDataOutput Class

Definition

Provides the structured interface through which a BackupAgent commits information to the backup data set, via its BackupAgent#onBackup(ParcelFileDescriptor,BackupDataOutput,ParcelFileDescriptor) onBackup() method.

[Android.Runtime.Register("android/app/backup/BackupDataOutput", DoNotGenerateAcw=true)]
public class BackupDataOutput : Java.Lang.Object
[<Android.Runtime.Register("android/app/backup/BackupDataOutput", DoNotGenerateAcw=true)>]
type BackupDataOutput = class
    inherit Object
Inheritance
BackupDataOutput
Attributes

Remarks

Provides the structured interface through which a BackupAgent commits information to the backup data set, via its BackupAgent#onBackup(ParcelFileDescriptor,BackupDataOutput,ParcelFileDescriptor) onBackup() method. Data written for backup is presented as a set of "entities," key/value pairs in which each binary data record "value" is named with a string "key."

To commit a data record to the backup transport, the agent's BackupAgent#onBackup(ParcelFileDescriptor,BackupDataOutput,ParcelFileDescriptor) onBackup() method first writes an "entity header" that supplies the key string for the record and the total size of the binary value for the record. After the header has been written, the agent then writes the binary entity value itself. The entity value can be written in multiple chunks if desired, as long as the total count of bytes written matches what was supplied to #writeEntityHeader(String, int) writeEntityHeader().

Entity key strings are considered to be unique within a given application's backup data set. If a backup agent writes a new entity under an existing key string, its value will replace any previous value in the transport's remote data store. You can remove a record entirely from the remote data set by writing a new entity header using the existing record's key, but supplying a negative dataSize parameter. When you do so, the agent does not need to call #writeEntityData(byte[], int). <h3>Example</h3>

Here is an example illustrating a way to back up the value of a String variable called mStringToBackUp:

static final String MY_STRING_KEY = "storedstring";

            public void {@link BackupAgent#onBackup(ParcelFileDescriptor, BackupDataOutput, ParcelFileDescriptor) onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState)}
                    throws IOException {
                ...
                byte[] stringBytes = mStringToBackUp.getBytes();
                data.writeEntityHeader(MY_STRING_KEY, stringBytes.length);
                data.writeEntityData(stringBytes, stringBytes.length);
                ...
            }

Java documentation for android.app.backup.BackupDataOutput.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

BackupDataOutput(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
Quota

Returns the quota in bytes for the application's current backup operation.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

TransportFlags

Returns flags with additional information about the backup transport.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteEntityData(Byte[], Int32)

Write a chunk of data under the current entity to the backup transport.

WriteEntityDataAsync(Byte[], Int32)
WriteEntityHeader(String, Int32)

Mark the beginning of one record in the backup data stream.

WriteEntityHeaderAsync(String, Int32)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to