jublikon
jublikon

Reputation: 3447

Bi-directional synchronization using Android Sync Adapter

Classic problem: Having a database on the server and a database on Android that both have to be kept synchronized (with a REST service).

After a lot of research it seems to be quite a good idea to use Android's Sync Adapter. I came over it reading about the Google's I/O App.

They use GCM to run the sync event. Please correct me if I am wrong, but this seems to be only one-directional synchronization.

Is there a way to use the Android Sync Adapter for bi-directional synchronization?

Upvotes: 0

Views: 379

Answers (1)

Marten
Marten

Reputation: 3862

The actual sync logic is performed by the Sync Adapter. That can be bi-directional or just uni-directional, whatever you need. This part has nothing to do with GCM.

Regarding the Google I/O App, they use GCM only to deliver a sync trigger to the app. That way the server can inform all clients about new content and the clients will fetch it (almost) immediately. Here is the relevant part:

To solve this problem in a more elegant way, we use GCM (Google Cloud Messaging). Whenever there is an update to the data on the server side, the server sends a GCM message to all registered devices. Upon receipt of this GCM message, the device performs a sync to download the new conference data. The GCMIntentService class handles the incoming GCM messages:

Triggering a sync upon a local change on the device is usually done by the ContentProvider that holds the data. So that's not an issue either.

Upvotes: 1

Related Questions