Why implement android SyncAdapter?

As an android developer you could be asking your self a question: Why implement android SyncAdapter?

It really depends on your android App.

When should you need to consider implementing SyncAdapter?

If you have not all ready watch Google I/O 2010 – Android REST client applications

If your app needs to sync local data (new/changed)  to your server.

A great example would be a note app. You want your user to have the ability to create notes without internet connection and on connectivity to the internet sync new/change notes.

SyncAdapter sync could be trigger by the user or by the system.

SyncAdapter requires:

1. Authentication -> to validate user and get token.

2. ContentProvider -> Local storage access (sqlite etc)

3.  Your Custom methods for syncing (SyncHelper).

Here is a quick flow chart that should help you to get a better understanding of SyncAdapter.



  1.  SyncAdapter is trigger, getAuthToken() from Authenticator
  2. If token Authenticator will return token else get token from system (if username and password stored in AccountManger) else show Login Activty/Fragment
  3. Validate user return token and add user to AccountManager
  4. SyncAdapter will pass token to processor (SyncHelper in my case)
  5. SyncHelper custom class has methods of checking your db if there is anything to sync.
  6. Content Provider will be used to get data from db and notify Fragments/Activities for changes (not in the diagram)
  7. Return data that needs to be synced.
  8. SyncHelper will get the data ready and pass it to HTTP Client
  9. HTTP  Client will process the request and send it to server
  10. HTTP Client will check if request data was OK if not send invalid Token Authenticator
  11. Return good data to SyncHelper, SyncHelper will send insert/update/delete as needed to Content Provider.

Leave a Reply

Your email address will not be published. Required fields are marked *