I am trying to implement the data backup in my application using data backup api.
The onBackup
method in the BackupAgent
helper class is never called. The Document says that the onBackup()
will be called some time in the future. Is there any specific time when the onBackup
will be invoked? Will it be invoked only once a day?
I tried to force the data backup on an emulator and a Nexus 7 device, using the following command:
adb shell bmgr backup <package>
adb shell bmgr run
The onBackup()
implementation was called on the emulator but on the device it was never called. Will the bmgr tool work on the device? Please help me to understand.
Check your Manifest file to see if under application you have
android:allowBackup="true"
as well asandroid:backupAgent
having the correct path to your projects FileBackupAgent. Also, your meta-data should have your registered key, such asandroid:value="your-registerd-key"
Make sure your device is connected to a Wi-Fi network. Also, make sure in your device Settings, the Backup and Reset needs to have "Back up my data" checked, and "Backup account" has a valid gmail account, and "Automatic restore" is checked.
You can see this by typing: bmgr list transports If transport is set to local, then enter:
adb shell bmgr transport com.google.android.backup/.BackupTransportService
Other
bmgr
commands to use to "kick" start your backup in https://www.google.com/settings/dashboard are:Refresh your https://www.google.com/settings/dashboard to see the latest backup timestamp