Android's backup service allows you to copy your persistent application data to remote "cloud" storage, in order to provide a restore point for the application data and settings. If a user performs a factory reset or converts to a new Android-powered device, the system automatically restores your backup data when the application is re-installed. This way, your users don't need to reproduce their previous data or application settings. This process is completely transparent to the user and does not affect the functionality or user experience in your application.

Note-: The backup service is not designed for synchronizing application data with other clients or saving data that you'd like to access during the normal application lifecycle. You cannot read or write backup data on demand and cannot access it in any way other than through the APIs provided by the Backup Manager.

Here is an example of Android Data Backup.

1.      Create an android project with minimum sdk must be greater than 8.

2.      Register for your Android Back Service from this link. 


Then click on Register with android backup service. It would give you your key, along with your AndroidManifest code to copy. Just copy the key. It is shown below: 

Your key is-:


3.      Add key value in your manifest.xml file







      android:value="AEdPqrEAAAAIErlxFByGgNz2ywBeQb6TsmLpp5Ksh1PW-ZSexg" />



Android provides BackUpAgentHelper class to handle all the operations of data backup. In order to use this class , you have to extend your class with it. My BackUpActivity class is

public class MyBackUpActivity extends BackupAgentHelper {


4.      Add following code in AndroidManifest.xml file 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
   android:versionName="1.0" >
      android:targetSdkVersion="18" />
      android:theme="@style/AppTheme" >
         android:label="@string/app_name" >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         android:value="AEdPqrEAAAAIErlxFByGgNz2ywBeQb6TsmLpp5Ksh1PW-ZSexg" />


5.      Paste following code in MyBackUpActivity.class 

package com.example.androidbackupexample; 
public class MyBackUpActivity extends BackupAgentHelper {
                static final String File_Name_Of_Prefrences = "myPrefrences";
                static final String PREFS_BACKUP_KEY = "backup";
                public void onCreate() {
        // A helper class hat can be used in conjunction with BackupAgentHelper
   //to manage the backup of SharedPreferences.
                                SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(


  Modified On Dec-01-2017 12:05:52 AM

Leave Comment