Android Backup Service provides a backup transport for Android's data backup framework, which allows you to copy a user's persistent app data to remote "cloud" storage. Backing up persistent data this way provides a restore point for the app on most devices running Android 2.2 or higher. The backup service is not designed for synchronizing application data with other clients or saving data that you'd like to access at random during the application lifecycle.
The Android Backup Service offered by Google provides a backup transport on most devices that include Google Play Store and backs up your app data to Google servers. The backup transport may differ from device to device and which backup transport is available on any device is transparent to your application.
In order to use Android Backup Service, you must register your app with the service to receive a key that you must include in your Android manifest.
Note: Registering your application with Android Backup Service does not guarantee that it will always back up data using this service from Google. If you support data backup in your application, then it will back up using whichever transport is enabled on the device. Registering with Android Backup Service allows your application to back up when the backup transport on the device is provided by Android Backup Service.
For more information about how data backup works on Android and how to use it in your app, read the Data Backup guide.
Adding the Backup Service Key to the Manifest
Once you register your app, you'll receive a Backup Service Key, which you must include in your Android manifest file with the following syntax:
<application> <meta-data android:name="com.google.android.backup.api_key" android:value="your_backup_service_key" /> ... </application>
Insert your Backup Service Key in the
android:value attribute and place the
<meta-data> element inside your Android manifest's
When a device that uses Android Backup Service runs your application, the system verifies that your Backup Service Key is valid and Android Backup Service saves the user's data to Google servers using the primary Google account on the device.
If your application
does not provide a valid Backup Service Key, then backup will not occur. If the device does not
provide backup using Android Backup Service, then the
<meta-data> element and
Backup Service Key are ignored—your application will work normally, but will either back up
data using a different backup transport or not perform backup at all. Either
way, your application is unaware of what transport is used, if at all, and otherwise
For more information about how to provide data backup in your Android application, see the Data Backup guide.
In addition, users can disable data backup functionality through the Android system's privacy settings. When a user disables backup, Android Backup Service deletes all saved backup data. A user can re-enable backup on the device, but Android Backup Service will not restore any previously deleted data.