Listing 1113 Android Manifestxml

<manifest xmlns:android="" package="com.cookbook.databackuprestore" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8"/> <application android:label="Backup/Restore"


<activity android:name="MyBandRActivity"> <intent-filter>

<action android:name="android.intent.action. MAIN"

<category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

Anytime the application triggers a backup or restore to the BackupManager, it initiates with the identified backup agent. For example, with the main activity excerpt as follows: public class MyBandRActivity extends Activity {

BackupManager mBackupManager; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

mBackupManager = new BackupManager(this);

void dataUpdate() {

// We also need to perform an initial backup; ask for one mBackupManager.dataChanged();

Inside the MyBandRActivity activity, the BackupManager instance is created in the onCreate() function.To ask for a backup, the dataChanged() function is called from the BackupManager.Then the BackupManager finds the BackupAgent defined in the AndroidManifest file and calls its onBackup() method.

Android provides two ways to trigger the restore.The first method is to use requestRestore() from the BackupManager.This method triggers a call to the backup agent's onRestore() method.Another way to trigger a restore is whenever the user does a factory data reset or when the application is reinstalled. The Android system then automatically triggers the restore for the application.

Besides triggering the backup and restore in an Android application, Android also provides a command-line script bmgr that can do the same thing. To trigger the backup, type

> adb shell bmgr backup <package>

To trigger the restore, type

> adb shell bmgr restore <package>

Whenever there is a backup request to the backup manager, it might not start the backup until a time it determines is appropriate.To force the BackupManager to do the backup right away, type

> adb shell bmgr run

Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook

Post a comment