When / Do Not Use Sync Adapter

I am trying to figure out if I need to use a sync adapter in an Android app.

An example of a procedural approach:

  • (With network coverage) Changes made by the user will automatically be sent to the server.
  • (WITHOUT network coverage) The changes will be saved in the sqlite table and wait for the online broadcast to download the changes.
  • Changes sent to the server will be saved in the mirroring of the sqlite table to some extent that is on the server.
  • Changes on the server will use the C2DM environment to notify users of the changes.
  • When the application receives a notification, it will retrieve the necessary data from the server and update the sqlite tables.

Question: Should I use a sync adapter for this to work? If so, what will be the high-level approach based on my example above. Thanks.

+6
source share
2 answers

Which server application do you want to synchronize with? If your application wants to synchronize user data with a server, C2DM (using a sync adapter) might be the way to go. It provides overhead. I found that in most cases it is easier to create and maintain a simple, quiet interface.

If you want a more detailed answer, you will need to provide additional information about your application.

+2
source

If you do not care about battery SyncAdapter , use the SyncAdapter for periodic bi-directional synchronization (up and downstream) and only change the local db to interact with the user action. Therefore, you only need two server-side scripts: one for downstream synchronization, and one for upstream synchronization.

Of course you need

1). 3, i.e. Insert_state, update_state and delete_state for local db to indicate dirty data.

2). uuid for local and remote db

RELATED GoogleIO SYNCHRONIZATION: http://www.youtube.com/watch?v=xHXn3Kg2IQE

+1
source

Source: https://habr.com/ru/post/917325/


All Articles