BackupAgentHelperpublic class BackupAgentHelper extends BackupAgent A convenient {@link BackupAgent} wrapper class that automatically manages
heterogeneous data sets within the backup data, each identified by a unique
key prefix. When processing a backup or restore operation, the BackupAgentHelper
dispatches to one or more installed {@link BackupHelper} objects, each
of which is responsible for a defined subset of the data being processed.
An application will typically extend this class in its own
backup agent. Then, within the agent's {@link BackupAgent#onCreate() onCreate()}
method, it will call {@link #addHelper(String, BackupHelper) addHelper()} one or more times to
install the handlers for each kind of data it wishes to manage within its backups.
The Android framework currently provides two predefined {@link BackupHelper} classes:
- {@link FileBackupHelper} - Manages the backup and restore of entire files
within an application's data directory hierarchy.
- {@link SharedPreferencesBackupHelper} - Manages the backup and restore of an
application's {@link android.content.SharedPreferences} data.
An application can also implement its own helper classes to work within the
{@link BackupAgentHelper} framework. See the {@link BackupHelper} interface
documentation for details.
Developer Guides
For more information about using BackupAgentHelper, read the
Data Backup developer guide.
|
Fields Summary |
---|
static final String | TAG | BackupHelperDispatcher | mDispatcher |
Methods Summary |
---|
public void | addHelper(java.lang.String keyPrefix, BackupHelper helper)Add a helper for a given data subset to the agent's configuration. Each helper
must have a prefix string that is unique within this backup agent's set of
helpers.
mDispatcher.addHelper(keyPrefix, helper);
| public BackupHelperDispatcher | getDispatcher()
return mDispatcher;
| public void | onBackup(android.os.ParcelFileDescriptor oldState, BackupDataOutput data, android.os.ParcelFileDescriptor newState)Run the backup process on each of the configured handlers.
mDispatcher.performBackup(oldState, data, newState);
| public void | onRestore(BackupDataInput data, int appVersionCode, android.os.ParcelFileDescriptor newState)Run the restore process on each of the configured handlers.
mDispatcher.performRestore(data, appVersionCode, newState);
|
|