public interface BackupHelper
BackupAgentHelperuses when dispatching backup and restore operations to the installed helpers. Applications can define and install their own helpers as well as using those provided as part of the Android framework.
Although multiple helper objects may be installed simultaneously, each helper
is responsible only for handling its own data, and will not see entities
created by other components within the backup system. Invocations of multiple
helpers are performed sequentially by the
BackupAgentHelper, with each
helper given a chance to access its own saved state from within the state record
produced during the previous backup operation.
|Modifier and Type||Method and Description|
void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState)
oldState, determine which of the files from the application's data directory need to be backed up, write them to
data, and fill in
newStatewith the state as it exists now.
Implementing this method is much like implementing
onBackup() — the method parameters are the same. When this method is invoked the
oldState descriptor points to the beginning of the state data
written during this helper's previous backup operation, and the
descriptor points to the file location at which the helper should write its
new state after performing the backup operation.
Note: The helper should not close or seek either the
newState file descriptors.
oldState- An open, read-only
ParcelFileDescriptorpointing 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- An open, read/write
BackupDataOutputpointing to the backup data destination. Typically the application will use backup helper classes to write to this file.
newState- An open, read/write
ParcelFileDescriptorpointing to an empty file. The application should record the final backup state here after writing the requested data to the
void restoreEntity(BackupDataInputStream data)
BackupAgentHelperto restore a single entity from the restore data set. This method will be called for each entity in the data set that belongs to this handler.
Note: Do not close the
data stream. Do not read more than
size() bytes from
data- An open
BackupDataInputStreamfrom which the backup data can be read.
void writeNewStateDescription(ParcelFileDescriptor newState)
BackupAgentHelperafter a restore operation to write the backup state file corresponding to the data as processed by the helper. The data written here will be available to the helper during the next call to its
This method will be called even if the handler's
restoreEntity() method was never invoked during
the restore operation.
Note: The helper should not close or seek the
ParcelFileDescriptorto which the new state will be written.