Opt out of an Android app with offline sync. Should I use SyncAdapter?

I am trying to make an Android To-Do client for a web service with offline caching and synchronization.

The web service returns JSON data about To-Do tasks on the server when you send a message to it. To add To-Do to the server, you need to send the JSON POST to the server with the details of the task, after which it will return the UUID task to you.

I want to implement some type of synchronization so that the tasks that I add when I am offline are sent to the server, and the data from the server is synchronized with the application (two-way synchronization) when the Internet is available.

I have currently written a basic To-Do content application that does not talk to the server. My question is, what would be the best way to implement such functionality?

Verification Planning

I believe that I need to get JSON from the server, insert it into the local SQLite database, perform comparisons and find the immutable elements and push them to the server. I think I can do this by adding asynchronous requests to my ContentProvider (not sure if this is the best way).

Que:

Should I write my own implementation of the same or can the SyncAdapter do all this magic? Are there any other design options that I should consider?

+8
android android-syncadapter
source share
2 answers

I think that it would be optimal for your problem to use GCM Push to transfer unsynchronized server data to your Android client. To synchronize SQL client data, you should know that it was not updated on the server, and whenever the device is connected to the network, click this data on the Server. A higher level of communication between the client and the server may implement a decision about what is unsynchronized. The above assumes that you have your own server with which your client will interact.

Given that you don't have your own server, your strategy for writing a sync adapter seems good. This link will help you learn the intricacies of the sync adapter.

+3
source share

To connect the library to your SyncAdapter and a demo application that demonstrates two-way synchronization of Google APIs for the local SQLite Android server, follow these steps: gitub repo:

https://github.com/sschendel/SyncManagerAndroid-DemoGoogleTasks

+5
source share

All Articles