Skip to content

Most visited

Recently visited


Backing up App Data to the Cloud

Users often invest significant time and effort creating data and setting preferences within apps. Preserving that data for users if they replace a broken device or upgrade to a new one is an important part of ensuring a great user experience. This section covers techniques for backing up data to the cloud so that users can restore their data.

To preserve as much of an existing user's experience on a new device as possible, make sure you backup the following user settings:

You must not backup URIs for ringtones because URIs are unstable. In some cases a restoration to a new mobile device may result in a URI which points to no ringtone, or a different ringtone from the one intended. Instead, you can backup ringtones using either their title or a hash of the ringtone.

Android provides two ways for apps to backup their data to the cloud: Auto Backup for Apps and Key/Value Backup. Auto Backup, which is available starting API 23, preserves app data by uploading it to the user's Google Drive account. The Key/Value Backup feature (formerly known as the Backup API and the Android Backup Service) preserves app data by uploading it to the Android Backup Service.

Generally, we recommend Auto Backup because it requires no work to implement. Apps that target Android 6.0 (API level 23) or higher are automatically enabled for Auto Backup. The Auto Backup feature does have some limitations in terms of what data it can backup and it's availability on Android 6.0 and higher devices. Consider using the Key/Value Backup feature if you have more specific needs for backing up your app data. For more information, see Comparison of Key/Value and Auto Backup.

You can also maintain existing user engagement on a new device by providing a seamless login experience. You can integrate Smart Lock for Passwords into your Android app to restore user sign-ins on a mobile device. Smart Lock for Passwords supports saving both username-password credentials and federated identity provider credentials.

For synchronizing app data, see Transferring Data Using Sync Adapters or Google Drive Android API. Neither backup approach is designed for ongoing synchronization of app data between Android-powered devices or saving data which you'd like to use during the normal application lifecycle. You cannot read or write backup data on demand. However, if your app doesn't have a backup mechanism for app contents and the size of your app contents is unlikely to exceed the 25 MB limit, then Auto Backup may be sufficient for your needs.

Note: If Wi-Fi isn't available, Key/Value Backup may use mobile data. Key/Value Backup is therefore typically not suitable for app data contents, such as media, downloaded files, and caches, unless the amount of data is very small.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.