Data Sync between Android apps in LAN

androidsynchronization

I am looking at developing an app which has quite an extensive database. This app will be installed on multiple devices in a LAN and all users can update the data and other users will see the data as it is synced.

We can use the network subscribe and poll feature in android to find available services but I was wondering how best to sync. We could log swap, CRUD etc via a Restful API. But i was wondering if there is another way.

Especially when new devices join the LAN and need a brand new database update.

Thoughts? Thank you in advance.

Best Answer

Data synchronization is a non-trivial problem. If you are not familiar with how to do it in a 'standard' program, tackling it in this context may be beyond your design capabilities. If you are familiar with data synchronization, the paper Data Synchronization Patterns In Mobile Application Design (McCormick and Schmidt from Vanderbilt) would probably be a good bit to read and build on your already existing knowledge (I'd also go and chase the references to other material that could be of use).

On the other hand, if you aren't familiar with data synchronization, you might want to instead look at using something that does it already. Unfortunately, I don't have a deep set of knowledge for mobile design... but I have used a NoSQL database that does do replication / synchronization between databases - CouchDB. This lead me to this article which is about mobile database synchronization with something called 'Couchbase Lite'. The github repo for it starts out with the claim:

Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.

and the mobile portal for the database again states:

Supports peer-to-peer replication. By adding an extra HTTP listener component, your app can accept connections from other devices running Couchbase Lite and exchange data with them.

This may be an appropriate tool to use. It is probably more reliable than rolling your own though it also means you're going to be using that database and having to fit to the way that it does things.