Android备份/还原示例不起作用? [英] Android backup/restore sample doesn't work?

查看:102
本文介绍了Android备份/还原示例不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了同样的问题-与Google开发人员小组中的问题相同.我引用了克里斯·格雷贝尔丁格(原始作者)的非常详尽的解释.

I'm having this same problem - as found in the google developer group. I quote what it is a very detailed explanation by Chris Grebeldinger (original author).

"在文档中: http://developer.android.com/guide/topics/data/backup.html#Testing

建议通过以下方式测试应用程序的备份/还原:

It recommends testing backup/restore of your application by:

  1. 安装您的应用
  2. 确保已启用备份/还原
  3. 更改一些数据并调用dataChanged()
  4. 强制bmgr运行备份通行证
  5. 卸载应用
  6. 重新安装该应用程序并检查您的数据是否已还原

在第4步之前,一切似乎都很好,当我在日志中看到这一点时:

All seems well until step 4, when I see this in the log:

V/BackupManagerService(306):removePackageParticipantsLocked:uid = 10078#1 V/BackupManagerService(306):删除com.example.app的备份知识

V/BackupManagerService( 306): removePackageParticipantsLocked: uid=10078 #1 V/BackupManagerService( 306): Removing backed-up knowledge of com.example.app

然后执行步骤5:

V/BackupManagerService(306):restoreAtInstall pkg = com.example.app令牌= 21 V/BackupManagerService(306):未设置还原-跳过还原

V/BackupManagerService( 306): restoreAtInstall pkg=com.example.app token=21 V/BackupManagerService( 306): No restore set -- skipping restore

因此,在卸载应用程序时,显然备份数据被破坏了,这意味着正式的测试工作流程可能无法正常工作吗?最好的测试方法是什么?"

So apparently backed up data is destroyed when an app is uninstalled, which means the official testing workflow can't possibly work right? What's the best way to test this?"

有人成功运行并测试了该样本吗?

Has anybody managed to run and test this sample correctly?

推荐答案

再次感谢克里斯·格雷贝尔丁格(Chris Grebeldinger),他很好地回答了我对他在google android开发人员小组中的原始帖子的答复.

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

它是如何工作的:

  • 在设备A中安装应用.
  • 在设备A中设置任何数据或首选项.
  • 强制在设备A上进行备份.(使用adb shell bmgr备份[app_name],运行adb shell bmgr).
  • 获取第二个设备B.
  • 在设备B上执行出厂重置.
  • 重置后,再次安装该应用程序.
  • 还原操作应该成功.

令我烦恼的是,Google Android文档中显示的步骤"似乎非常详细,因此决定忽略它是必需的和强制性的步骤.

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.

谢谢.

在使用不同设备进行进一步测试之后,似乎整个备份/还原过程可能会因制造商和设备而异.我可以使用Google的文档方法来测试示例应用,即巧合地通过使用nexus 7进行卸载和安装.因此,我的建议是不要在测试期间期望相同的行为和一致性.

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.

这篇关于Android备份/还原示例不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆