共用方式為


BackupAgent.OnBackup Method

Definition

The application is being asked to write any data changed since the last time it performed a backup operation.

[Android.Runtime.Register("onBackup", "(Landroid/os/ParcelFileDescriptor;Landroid/app/backup/BackupDataOutput;Landroid/os/ParcelFileDescriptor;)V", "GetOnBackup_Landroid_os_ParcelFileDescriptor_Landroid_app_backup_BackupDataOutput_Landroid_os_ParcelFileDescriptor_Handler")]
public abstract void OnBackup (Android.OS.ParcelFileDescriptor? oldState, Android.App.Backup.BackupDataOutput? data, Android.OS.ParcelFileDescriptor? newState);
[<Android.Runtime.Register("onBackup", "(Landroid/os/ParcelFileDescriptor;Landroid/app/backup/BackupDataOutput;Landroid/os/ParcelFileDescriptor;)V", "GetOnBackup_Landroid_os_ParcelFileDescriptor_Landroid_app_backup_BackupDataOutput_Landroid_os_ParcelFileDescriptor_Handler")>]
abstract member OnBackup : Android.OS.ParcelFileDescriptor * Android.App.Backup.BackupDataOutput * Android.OS.ParcelFileDescriptor -> unit

Parameters

oldState
ParcelFileDescriptor

An open, read-only ParcelFileDescriptor pointing to the last backup state provided by the application. May be null, in which case no prior state is being provided and the application should perform a full backup.

data
BackupDataOutput

A structured wrapper around an open, read/write file descriptor pointing to the backup data destination. Typically the application will use backup helper classes to write to this file.

newState
ParcelFileDescriptor

An open, read/write ParcelFileDescriptor pointing to an empty file. The application should record the final backup state here after writing the requested data to the data output stream.

Attributes

Exceptions

Remarks

The application is being asked to write any data changed since the last time it performed a backup operation. The state data recorded during the last backup pass is provided in the oldState file descriptor. If oldState is null, no old state is available and the application should perform a full backup. In both cases, a representation of the final backup state after this pass should be written to the file pointed to by the file descriptor wrapped in newState.

Each entity written to the android.app.backup.BackupDataOutputdata stream will be transmitted over the current backup transport and stored in the remote data set under the key supplied as part of the entity. Writing an entity with a negative data size instructs the transport to delete whatever entity currently exists under that key from the remote data set.

Java documentation for android.app.backup.BackupAgent.onBackup(android.os.ParcelFileDescriptor, android.app.backup.BackupDataOutput, android.os.ParcelFileDescriptor).

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.

Applies to