views:

26

answers:

1

I need to sync my Android SQLite DB with my cloud-server DB, and doing it in a bi-directional way in a multiuser environment.

I have found and introduction to the solution here (http://blog.deeje.tv/musings/2009/06/notes-on-writing-a-history-driven-client-server-synchronization-engine.html) but I would like to read about a better solution/algorithm.

A: 

I'd recommend to send db file to your server and do merging on the server side. Then send merged db back to the client if needed. Your solution will vary based on conflict resolve algorithm and your database schema. But here is example for the simplest case:

sqlite> attach 'client.db3' as ClientDBtoMerge;           
sqlite> insert into TableName select * from ClientDBtoMerge.TableName;
sqlite> detach database ClientDBtoMerge; 

Hope you are be able to modify example for bi-directional merge.

cement
Could be a solution for backup in a monouser environment. But for multiuser cann't. Thanks anyway.
Juanin
Why not? You can have master database on a server and merge it on request-by-request basis or all together. Or you need real-time sync between databases? In the case you are talking about replication which is impossible because you need 100% online time of all your client phones.
cement