Reputation: 2661
I am trying to sync data between android application and php server.
In my application I use json webservices to get data from php server.
Now whenever there is new fields added to php server database then my app should reflect it immediately.
Its kind of background services which we look everytime for the new data to php server database.
How can i do this ?
Upvotes: 4
Views: 2651
Reputation: 12615
Have a look at SyncAdapter class especially designed for this purpose. http://developer.android.com/training/sync-adapters/index.html
Upvotes: 0
Reputation: 35970
If you need this immediately, you should consider using GCM.
This sentence is on the GCM's front page:
Send data from your server to users' Android-powered devices. This could be a lightweight message telling your app there is new data to be fetched from the server
What you would need to do is to make your backend notify GCM about new data (via GCM's web service). Then, it's GCM's responsibility to deliver this message to your app. It'll even launch app when it's not running.
As for specific solution, you have two possibilities: either backend will only "ping" app via GCM, and app will fetch data by itself, or, if the update is small, backend could send it to your app directly in the GCM message.
Upvotes: 5