This library will help you synchronize databases across all mobile devices that uses your application. Library provides fast master-master replication that synchronizes application's database on any Android mobile device with remote PostgreSQL database. Remote database serves as middleman, it's always available and helps with synchronization.
- fast
- easy to use
- automatic conflict resolution
- minimal database usage restrictions
- minimal hardware requirements
- logs conflicts
- custom server with PostgreSQL database (MySQL supported soon)
- knowledge about master-master replication limitations (see Oracle article)
These are necessary steps to set up the library. If you don't follow described steps, synchronization might not work correctly.
- Install Android SDK, which also contains Eclipse. See Android SDK (Note: Google will soon provide custom IDE).
- Import this library to Eclipse. Click on Import in File menu. Select Android > Existing Android Code Into Workspace and click on Next then Browse and select folder with this library. Then click on Finish.
- Create your own project by clicking on Android Application Project in File > New menu.
- Right click on your project, click on Properties, choose Android, click on Add... in Library tab and then add SQLsync library.
- Add "manifestmerger.enabled=true" into "project.properties" file that is part of your project.
- Set your timezone for your Android emulator by clicking on Debug Configuration in Run menu. Then click on Target tab. In text field Additional Emulator Command Line Options enter your timezone, e.g. "-timezone Europe/Berlin".
- Extend SyncDatabaseHelper class and adapt it to your own liking. See SampleDatabaseHelper class in SampleSQLsync how to use it.
- Extend SyncProvider class. See SampleProvider for reference.
- Upload webservice files from "SQLsync-webservice" folder to your server.
- Create custom script for creating your own database structure, execute it and remove from server to avoid misuse. See file SampleCreateDatabase.php.
- In file SyncSettings.php set accepted name and password.
- Use SyncExecutor.createAccount(name, password, getApplicationContext()) to create synchronization account. Name and password will be send to the webservice on your remote server.
- Use class SyncSettings in package "com.rathma.sqlsync.settings" to define tables for synchronization. Set URL address to webservice in field URL_WEBSERVICE. Set AUTHORITY field to name of your project's package.
- Set res/value.xml to name of your project's package.
This library is supplied with a simple sample application that demonstrates how to properly use it.