ContentProvided defined for synchronization is dummy (in accordance with this approach).
Asked
Active
Viewed 2,574 times
3
-
Looks like addPeriodicSync is a key, but it requires API 8 – LA_ Apr 02 '11 at 20:52
1 Answers
14
If API > 8, (95% of devices) use ContentResolver.addPeriodicSync()
If API = 7, (5.5% of devices as of Mar 2102) create a service with a periodic timer callback, and call ContentResolver.requestSync()
.
API < 6 does not support syncAdapter, so no worries.

jcwenger
- 11,383
- 1
- 53
- 65
-
Thanks. API = 7. So, looks like there is no much sense for me to support synchronization thru SyncAdapter - Service would be enough (I need to sync data with my local database, it can be done without account). – LA_ Apr 04 '11 at 15:40
-
1You should definitely be using a SyncAdapter and ContentProvider. Just because you're not sharing externally doesn't mean you should be doing it all by hand. ContentProvider is a great, clean interface and ensures all your database work happens in a background thread. Prevents ANR errors etc. Keep at it, it's the way to go. – jcwenger Apr 04 '11 at 15:42
-
Now nearly every device is API 8 or higher. You will probably have a few users with older versions, but very few and they will likely upgrade soon. – Patrick Jackson Jul 07 '12 at 17:03
-
If I don't use any function for syncing, what would be the behavior of it? Also, is it possible to define it in XML ? What if I want to disable syncing? – android developer Sep 11 '13 at 06:32
-
@androiddeveloper, I don't understand your questions. Post a proper new question instead of comment replies and I'll work on answering it. – jcwenger Sep 11 '13 at 13:49
-
@jcwenger i meant, what if i don't call "addPeriodicSync"? in which cases would the "onPerformSync" be called? how often? the second question was if it's possible to use "addPeriodicSync" in xml instead of in code. the third question was how to disable the syncing altogether via xml . – android developer Sep 11 '13 at 13:56
-