I want to backup my app\'s data using Android backup service, but I\'m concerned about network usage. I have about 500KB of data that needs to be uploaded for each backup op
I've dove further on researching the Android Backup Manager Service and discovered the following:
I interpret this as each DataChanged() call in our App notifies the Backup Manager Service via transport. The Backup Manager Service will only perform ONE call to our App's Backup Agent's onBackup(), even if DataChanged gets called several times before the Backup Manager Service responds when it wants to (see item 2 below on Backup Manager respond frequency).
There are 2 parts to your question:
Let's start with #2, how often. I think the documentation sufficiently answers this. Any time your app calls the dataChanged()
method, there is the possibility of a backup. Thus would be prudent to limit the frequency of calls to this method. It is up to you how to handle this. One approach you might want to consider it to only call this for significant/important data changes in your app. That is, do not call it for changes to user preferences (like background color e.g.), but do call it for any sort of transactional data.
As for #1, when: That is harder to answer exactly. The documentation is noncommittal about this. This gives Android the freedom to change this algorithm, without violating any developer expectations. I do think it is reasonable to assume the following: the backup is likely to happen quickly, probably at the soonest time conditions are appropriate. If it did not happen "soon", then it would not be a very useful service, would it? There are probably some simple conditions that Android waits for (just a guess but this might be available threads, available network connection with no other network activity). Note that the documentation states "it will back up using whichever transport is enabled on the device". That sounds like it is designed to make the backup happen as early as possible.