Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android application offline mode, local sqlite database synchronisation with distant database

I have a postgreSql database which is manipulated by an android application via Web Services. I'd like to know what is the best way to make an offline mode for my application.

My first idea was to make an sqlite local database used when the device has no access to web

I'd like to know if there is an existing tool, that makes synchronisation easier with the existing postgres database once the device have access to web

like image 701
Simo Avatar asked Mar 28 '13 18:03

Simo


1 Answers

Here are some very basic thoughts on this.

In an ideal case, you'd sync in general working meta-data and your off-line mode would allow insert-only workflows adding new data based on that metadata. This would make it fairly easy to sync things through later by merely posting to a web service sequentially and then flagging as such in the db or removing the rows altogether.

If you go with something like that, you probably don't really want to approach sqlite as an rdbms. What you probably want is a wide table structure designed mostly to store pending requirests, or something that will store things like json payloads you will send later. This means your local db will be designed not around your data model but around your web service API.

If you have to get into update (overwriting workflows) then you need to put a lot of effort into conflict resolution but the same basically applies. You probably want to add a lot more information like timestamps and other conflict-resolution-related data.

From there however you should be able to re-use your application API to do the sync rather than looking for a specific tool to do it.

like image 151
Chris Travers Avatar answered Sep 22 '22 14:09

Chris Travers