An Android service that synchronizes data between an Android device and a server
A SyncAdapter
is an Android Service
that synchronizes data between an Android device and a backend server. SyncAdapter
s can be part of an Android program, or can be a standalone entity. SyncAdapter
s are associated with an Account
, which defines a collection of data that belongs to a specific application.
The purpose of a SyncAdapter
is to ensure that data is kept consistent on the Android device and a server. When the data is changed on the server, the SyncAdapter
must identify that a change has been made, and update the data on the Android device to reflect the change.
The most common type of data that is synchronized using SyncAdapter
s are your Contacts list. Whenever you add a contact on your phone, the contact is also sent to the Google server and stored within. Similarly, if you add a contact from a different Google service, such as GMail, the SyncAdapter
will identify that a contact has been added, and replicate the data onto your Android device.
Any type of data can be synced with a backend server, its only dependent on the type of data that your application is dealing with. Other common data types to be synced in this way are Calendars and To-Do/Task lists.
The reason why SyncAdapter
s exist is to create a local copy of the data, so that it can be accessed quickly without the need for a data connection. For example, if your contacts are kept synced, then you can access your contacts quickly on your Android device regardless of whether you have data access or not - it's all locally-stored data independent from network requirements.
SyncAdapter
s will usually send a 'check' message to the server on a periodic basis, say every 30 minutes, to ask whether any changes have been made during this time. This is only a small data exchange, and doesn't consume much network data. Further 'synchronization' steps only occur if the data has changed and needs to be updated on the Android device accordingly.