安卓备份接口(interface)

标签 android cloud sync

谁能解释一下 Android Backup API 的确切用途?

我已阅读 Using the Backup APIData Backup来自 Developer Docs,但我仍然不清楚。

何时备份和恢复数据?

特别是在这些情况下:

  1. 用户在设备 1 上安装了我的应用程序,备份了数据,然后用户在设备 2 上安装了我的应用程序。设备 1 中的用户数据是否会自动放在设备 2 上?如果是,这是在安装应用程序时还是在启动应用程序时发生的?

  2. 我的应用安装在 2 台设备上。当在设备 1 上进行更改时,它会自动在设备 2 上进行吗?如果不是,是否至少可以在设备 2 上进行更改?

在一个文档中,它说

The backup service is not designed for synchronizing application data with other clients or saving data that you'd like to access during the normal application lifecycle. You cannot read or write backup data on demand and cannot access it in any way other than through the APIs provided by the Backup Manager.

但在另一个方面,

the Android framework helps you build rich cloud-enabled apps that sync their data to a remote web service, making sure all your devices always stay in sync

这对我来说似乎是矛盾的。

更具体地说,我想跨设备持续同步单个数据库文件(小于 20 KB)。这可以通过备份 API 实现吗?

最佳答案

编辑:所以回答您的问题 - 不,这不是同步数据的可靠方式。

When a user purchases a new device or resets their existing one, they might expect that when Google Play restores your app back to their device during the initial setup, the previous data associated with the app restores as well. By default, that doesn't happen and all the user's accomplishments or settings in your app are lost.

据我所知,您的应用正在将数据存储到云端。您将文件推送到备份服务器,并使用 API key (每个用户的谷歌帐户都是唯一的)允许您将备份下载到其他设备,但只能在安装应用程序期间或通过手动请求进行访问。文档指出:

The backup service is not designed for synchronizing application data with other clients or saving data that you'd like to access at random during the application lifecycle.

据我了解(我自己没有实现过)您不能将其用作云同步实时数据的可靠方法。

list 可能会启动您的数据处理并确定是否应推送备份。

At some point in the future, the backup manager then calls your backup agent's onBackup() method

恢复备份不是手动的:

Typically you shouldn't ever have to manually request a restore, as it happens automatically when your application is installed on a device. However, if it is necessary to trigger a manual restore, just call the requestRestore() method.

关于安卓备份接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14299678/

相关文章:

asp.net - Azure:如何在一个虚拟网络中将一项云服务与其他云服务连接

api - Google Cloud Console 中的重定向 URI 未保存

android - 带标签/标签的照片的云存储架构/解决方案

使用 Google 日历的 Android 应用程序 - 同步问题

android - 获取大量数据会抛出光标窗口 : Window is full error

android - 从 native 代码读取 Android 相机设备,无需 root

amazon-s3 - 排除 s3cmd 同步的文件夹

linux - O_SYNC 写入何时在页面缓存(mmap 文件)中可见?

android - 如何使用 gradle 从 maven repo 中正确删除传递依赖

java - Android注入(inject)类返回null