I am developing an app that uses an SyncAdapter
on the android client to synchronized data with a Google Cloud Store
( GCS
) backend.
The adapter is working perfectly. Now my doubt is how to properly design the synchronization/merging algorithm taking into account the following issues:
GCS
could have changed since the last sync by another device. I know how to read/write data from the GCS and manipulate it on the device, but not sure whether there is out-of-the-box functionality to perform this task of if I should implement my own from scratch.
Any example or hint would be really appreciated.
Simplest solution is to mark all changes (records?) with 'modified_date' and update records only with older modify date. If modify date is newer it means a collision/conflict (someone updated record before you were able to do that) - then, you can overwrite data or discard your changes.
I think the best way to do this is by following the example implemented in here: https://code.google.com/p/jumpnote/
The example is missing the GCS part, but all the merging logic is in there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.