什么是 Android 应用自动备份?

What is Android Auto Backup for Apps?

@so 关于Android 自动备份的问题很少。我之前没有使用过这个,所以先阅读文档! https://developer.android.com/guide/topics/data/autobackup.html#Files

然后我制作了一个示例应用程序,并设法添加到已在 Google 驱动器中备份的应用程序列表中。

但我还是想从中清除一些东西,因为它比文档更容易理解。

这里有几点我搞砸了。

恢复计划

The device can restore from either its own backups or the ancestral dataset. The device prioritize its own backup if backups from both sources are available. If the user didn't go through the device setup wizard, then the device can restore only from its own backups.

启用和禁用备份

<application ...
    android:allowBackup="true">
</app>

To disable Auto Backup, set android:allowBackup to false. You may want to disable backups when your app can recreate its state through some other mechanism or when your app deals with sensitive information that should not be backed up

谢谢

Not at what stage it takes the backup? Do i need to follow any technique eg: like a splash till it completes onRestoreFinished()? if there is like 20 MB data? Any good example for this?

幸运的是我们开发者,这是在应用程序安装过程中自动完成的,这可能发生在几种情况下:

Data is restored whenever the app is installed, either from the Play store, during device setup (when the system installs previously installed apps), or from running adb install. The restore operation occurs after the APK is installed, but before the app is available to be launched by the user.

来自restore schedule


This line is in the Manifest so what can be the best way to make it false once the backup task is done.Let's say registration is done and that's all i want to back up.How can I update that tag value at run time?

那是不可能的。正如您在 Backup schedule 中所读到的,它会以某种固定的间隔自动完成。如果您有与此计划冲突的需求,您必须实施自己的备份机制。


Is there any way to reset 25MB backup quota by deleting the existing backup?

这不是必须的。一次只存在一个备份。进行新备份时,旧备份将被删除:

Backup data is stored in a private folder in the user's Google Drive account, limited to 25MB per app. The saved data does not count towards the user's personal Google Drive quota. Only the most recent backup is stored. When a backup is made, the previous backup (if one exists) is deleted.

来自backup location