Android Development – Design for Syncing Data in Android

androidandroid-development

I have been seeing two implementations for syncing data between the server and the client on majority of the apps. This assumes no GCM is set up:-

  1. Running an intent service periodically which downloads the data from the network and stores in the database.
  2. Implementing a Sync Adapter which runs periodically.

Which of the above would you recommend to have in your app and why?

Best Answer

Note: Sync adapters run asynchronously, so you should use them with the expectation that they transfer data regularly and efficiently, but not instantaneously. If you need to do real-time data transfer, you should do it in an AsyncTask or an IntentService. - source.

Basically, if you need real time transfer use IntentService (the first option), else SyncAdapter. I prefer an IntentService though because it feels more customizable, but a more trivial approach would be to use a SyncAdapter.

Related Topic