Android Backup API

Can anyone explain what exactly the Android Backup API is used for?

I read Using the Backup API and Backing Up Data from Developer Docs, but I still don't understand it.

When is data backup and recovery performed?

In particular, in the following situations:

  • The user installs my application on device 1, the data is backed up, and then the user installs my application on device 2. Is the user data from device 1 automatically placed on device 2? If so, does this happen when the application is installed or when it is running?

  • My application is installed on 2 devices. When a change occurs on device 1, is it automatically executed on device 2? If not, is it possible to make this change on device 2?

One document says:

The backup service is not intended to synchronize application data with other clients or to save data that you want to access during the normal application life cycle. You cannot read or write backup data on demand and cannot access it in any way except through the API provided by the backup manager.

But in another,

The Android platform helps create rich cloud-enabled applications that synchronize their data with a remote web service, ensuring that all your devices stay in sync

This seems to be a contradiction.

In particular, I want to constantly synchronize one database file (less than 20 KB) on different devices. Is this possible with the backup API?

+8
android cloud sync
source share
2 answers

Edit: So, to answer your question - no, this is not a reliable way to synchronize your data.

When a user buys a new device or resets an existing one, they can expect that when Google Play restores your application back to their device during initial setup, the previous data associated with the application will also be restored. By default, this does not happen, and all user achievements or settings in your application are lost.

As I can see, your application stores data in the cloud. You transfer files to backup servers and using the API key (which is unique for each google user account) allows you to download a backup to other devices, but can only be accessed when installing the application or performing a manual request. The documentation states:

The backup service is not intended to synchronize application data with other clients or to save data that you would like to access accidentally during the application life cycle.

As I understand it (without doing it yourself), you cannot use this as a reliable method for real-time cloud data synchronization.

the manifest will probably start processing your data and determine whether to back up.

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

Restoring a backup is not manual:

Normally, you don’t need to manually request recovery, as it does automatically when your application is installed on the device. However, if you need to start manual recovery, just call the requestRestore () method.

+3
source share

Sigh, the documentation should not mention “synchronization” anywhere. I have to submit some corrections in order to fix this. :) This mechanism is not intended for the exchange of data between two devices.

The main goal of the backup infrastructure in Android is to provide your users with a good experience when they set up a new device, for example, when they buy a tablet to work with their phone or when the device crashes and breaks, and they created a replacement. The idea is that the newly configured device is in a familiar state, while all the same applications and their data remain intact, the same wallpaper for images, when applicable, etc.

Saving real-time data between devices is what Sync Manager is designed for.

0
source share

All Articles