In my app, I have to consume REST API for syncing data between server and SQLite DB in app.
I have one activity like To-Do's in which all the To-Do's post on server will notify by the push notification to app. Now, lets check senario.
Senario 1
There are 3 To Do 's on server
- Note 1
- Note 2
- Note 3
There are three To Do's on ther server and all of them are synced and stored in SQLite in the app. And only new notes are synced in the app by requesting for new notes using timestamp stored in SharedPrefs when user opens the app. But, what if -Note 2 is altered on server(MySql DB) than,
- How to sync the updated or deleted notes in app with minimum N/W calls.
- Can we fire push notifs(silently) to inform the app there is altered data on server, so it can be synced on next startup of the app.
I have search for this problem but cannot find appropriate solution.
解决方案
There is very Good Topic in android Sync Adapter. Its worth giving it a try. See the reference link from Android Developer website