Android backup/restore sample doesn't work?

心已入冬 提交于 2019-12-04 08:35:56

Thanks again to Chris Grebeldinger which kindly answered my reply to his original post in the google android developer group.

How it does work:

  • Install the app in device A.
  • Set any data or preferences in device A.
  • Force a backup on device A. (Using adb shell bmgr backup [app_name], adb shell bmgr run).
  • Grab a second device B.
  • Perform a factory reset on device B.
  • Once reset, install the app again.
  • The restore operation should be successful.

What annoys me is that the "steps" as shown on the Google Android documentation which appear to be quite detailed decided to omit what it appears to be a necessary and compulsory steps.

As Chris mentioned on his reply, I hope this helps other people who find the same problem.

Thanks.

EDIT:

After further testing with different devices, it appears that the whole backup/restore process can vary from manufacturer and device. I could test the sample app using Google's document approach i.e. by uninstalling and installing using a nexus 7 - just by a coincidence. So, my advice would be not to expect the same behaviour and consistency during your tests.

Kamil Seweryn

Try using the emulator for testing purposes. Nexus 5 with API 22 worked for me just by uninstalling and installing the app.

Full process:

  1. Enable backup by adb: bmgr enable true
  2. Set local transport: bmgr transport android/com.android.internal.backup.LocalTransport
  3. Run your app and prepare for backup
  4. Run backup: bmgr backup <package> & bmgr run
  5. Uninstall app from emulator
  6. Install the app again - restore should happen automatically

Tip: lookup logcat for "backup" activities

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!