THRTY5
THRTY5

Reputation: 31

How to keep data sync in android

Case : I am running a application in android, now how i do get know whether the server data has been changed as it can be changed from my website. Mechanism i can think of is: a) i should call server periodically and check whether the data has been changed recently by maintaining e-tag over there b) implement push notification and on getting a push notification i will call the server for the data change

Can there be something much than this, the other part is which one is the better approach(a,b) or both are obsolete?

Upvotes: 0

Views: 334

Answers (2)

João Parreira
João Parreira

Reputation: 132

Use a pub/sub cloud messaging service like Pusher or Realtime.co

Subscribe a data-updated channel on the Android app and publish a message containing the updated data or the updated data id so the app can retrieve it from your backend.

Realtime.co will even give you an automatic fallback to mobile push notifications using GCM and APNS.

With this approach and using the referred services you'll get a cross-platform solution as a bonus since they have multiple SDKs. If some day you want to build an ios app we can reuse what you already have in place for the Android and Web platforms.

Upvotes: 0

itai
itai

Reputation: 294

My Opinion is you're asking the wrong question the question is when the user need to know there is new data,if the answer as soon as the data is updated then push would be your way if it's when he is asking for it than go with a. hope this is useful.

Upvotes: 1

Related Questions