Reputation: 2792
I've been thinking about this scenario.
Let's say I have a SQLite
database wrapped in a ContentProvider
, The data in the database is sent to a webservice thorugh a SyncAdapter
which runs every 10 minutes.
To know which rows have been sent to the webservice, an state column is used (0 = not sent, 1 = sent).
The app UI is a list filled using a LoaderManager.LoaderCallbacks
, and another view(a form) in which the user inputs the data.
The SyncAdapter
uses the onPerformSync
's ContentProviderClient
parameter to query the data not sent (0) and to update the rows to a sent state(1)
The cause of my confusion is the scenario in which the already sent data can be re-sent several times. the user opens an already sent form and edits its data, which changes the state column to 0, so the syncadapter picks the edited row.
Now, Let's say the sync adapter picks a row and begins to send the data, meanwhile the user opens the same data row, edits some columns and updates. Then when the webservice finishes receiving the data, the sync adapter updates the state column to 1.
Now the row contains data that is not going to be sent. right?
should I just compare all the data I sent with the one in the database before updating from the sync adapter, is that the approach? Or could I use the framework to handle the situation in a more sophisticated manner?
Looking forward to hear what is you experience with that situation.
Upvotes: 0
Views: 131
Reputation: 6968
As @CL. correctly said you have more than 2 states.
a simple solution can be locking the rows from being edited while they are in transition.
Upvotes: 1
Reputation: 180020
You found that you have more than two states:
Upvotes: 2