I'm developing an application and I would like to implement a feature where it would be possible to share, lets say, favourites, bookmarks, etc, between the same user devices. So, I want to achieve something like iCloud.
I came across 2 possible ideas: Backup Manager and Google Drive. I think Backup Manager is the simplest solution and would fit my needs but maybe I'm wrong:
Note: 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.
Note: The backup transport provided by Android Backup Service is not guaranteed to be available on all Android-powered devices that support backup. Some devices might support backup using a different transport, some devices might not support backup at all, and there is no way for your application to know what transport is used on the device.
Since I'm storing this information in SharedPreferences I started my implementation by extending BackupAgentHelper as Google advises (http://developer.android.com/guide/topics/data/backup.html#BackupAgentHelper).
...each time the user changes some data, your app should call dataChanged(), which adds a backup request to the Backup Manager queue.
So, each time I change data, save or remove a bookmark for example, I call:
BackupManager.dataChanged(C.PROJECT_PATH);
When my applications starts I call:
contentBackupManager.requestRestore(new RestoreObserver() {})
Everything is setup and AndroidManifest.xml too.
Unfortunately requestRestore is returning != 0 (error) and my BackupAngent (extends BackupAgentHelper) onBackup and onRestore aren't being called (onCreate is). But, once again:
A backup request does not result in an immediate call to your onBackup() method. Instead, the Backup Manager waits for an appropriate time, then performs backup for all applications that have requested a backup since the last backup was performed.
Does this means I'll only find my answer in Google Drive?
You are correct that you shouldn't use BackupManager for this. You will need to use a third-party service that will hold your exact type of data. So you can either:
You pick :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With