Partager via


BackupDataInput Class

Definition

Provides the structured interface through which a BackupAgent reads information from the backup data set, via its BackupAgent#onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor) onRestore() method.

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

Remarks

Provides the structured interface through which a BackupAgent reads information from the backup data set, via its BackupAgent#onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor) onRestore() method. The data is presented as a set of "entities," each representing one named record as previously stored by the agent's BackupAgent#onBackup(ParcelFileDescriptor,BackupDataOutput,ParcelFileDescriptor) onBackup() implementation. An entity is composed of a descriptive header plus a byte array that holds the raw data saved in the remote backup.

The agent must consume every entity in the data stream, otherwise the restored state of the application will be incomplete. <h3>Example</h3>

A typical BackupAgent#onRestore(BackupDataInput,int,ParcelFileDescriptor) onRestore() implementation might be structured something like this:

public void onRestore(BackupDataInput data, int appVersionCode,
                                  ParcelFileDescriptor newState) {
                while (data.readNextHeader()) {
                    String key = data.getKey();
                    int dataSize = data.getDataSize();

                    if (key.equals(MY_BACKUP_KEY_ONE)) {
                        // process this kind of record here
                        byte[] buffer = new byte[dataSize];
                        data.readEntityData(buffer, 0, dataSize); // reads the entire entity at once

                        // now 'buffer' holds the raw data and can be processed however
                        // the agent wishes
                        processBackupKeyOne(buffer);
                    } else if (key.equals(MY_BACKUP_KEY_TO_IGNORE) {
                        // a key we recognize but wish to discard
                        data.skipEntityData();
                    } // ... etc.
               }
            }

Java documentation for android.app.backup.BackupDataInput.

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

BackupDataInput(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)
DataSize

Report the size in bytes of the data associated with the current entity in the restore stream.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Key

Report the key associated with the current entity in the restore stream

PeerReference (Inherited from Object)
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.

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)
ReadEntityData(Byte[], Int32, Int32)

Read a record's raw data from the restore stream.

ReadEntityDataAsync(Byte[], Int32, Int32)
ReadNextHeader()

Extract the next entity header from the restore stream.

ReadNextHeaderAsync()
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SkipEntityData()

Consume the current entity's data without extracting it into a buffer for further processing.

SkipEntityDataAsync()
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)

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