Reputation: 57
I am syncing using SyncAdapter
, custom ContentProvider
and AccountManager
services. I am a bit stucked with the synchronization implementation. I have been greatly helped by the SDK example "SampleSyncAdapter" for Contacts which stores the mobile device IDs (_id
in Android) in the server tables so when it responds with the dirty list, the device knows whether to add or update content.
Does this pattern mean that I have to add a new server side columns for every client? I might support other platforms in the future (e.g. iPhone data IDs - I'm not familiar with its SDK).
Upvotes: 0
Views: 787
Reputation: 17087
Use a mapping table in your server side database.
Basically:
DeviceID | DeviceItemID | ServerItemID
Dev1 100 8912831
Dev1 101 8819111
Dev1 108 7717719
Dev2 971 12091231
.... ... ........
Joining this table with the server items allows you to filter out and find exactly what identifiers exists on the device.
This is the approach used in the legacy synchronization protocol OMA DS (you'd find this in Nokia phones etc.).
This would be preferable if you're going for "multi-client" synchronization, i.e. one specific data set on the server is shared among several clients - you could for instance add columns to the mapping table (such as change counters/last-modified) to allow your server to find the updated/deleted and added items & only send them.
Upvotes: 1