Mobile replication with Android edge devices in near real time to an on-premise or cloud based database or warehouse. Through a simple integration into your Android application you can unleash the full replication power of the SymmetricDS platform with your mobile devices running Android.
Why Use SymmetricDS For Mobile?
- Subset data that is sent to Android edge devices. Reduces the amount of data maintained on each device.
- Avoid vendor lock with SQLite on Android to any relational database you need on-premise or in your cloud warehouse.
- Bidirectionally sync data from one Android device to central back out to other Android devices at a table level.
- Transform data or schemas between your Android devices and central.
Get Started : Android Studio
Download Android Studio
Setup
- Create a new project in Android Studio.
- Add the symmetric-pro-android jar file to the build gradle file.
Kotlin/Gradle
dependencies {
implementation("org.jumpmind.symmetric:symmetric-pro-android:3.15.0") {
exclude(group = "org.slf4j", module="slf4j-api")
exclude(group = "org.slf4j", module="jcl-over-slf4j")
exclude(group = "org.apache.logging.log4j", module="log4j-slf4j-impl")
exclude(group = "org.apache.logging.log4j", module="log4j")
exclude(group = "org.apache.logging.log4j", module="log4j-core")
}
}
Maven
dependencies {
implementation"org.jumpmind.symmetricds:symmetric-pro-android:3.15.0"
}
Android Activity Code
Add the following code to your default activity.
Database Helper
Create database constants and an implementation of the SQLiteOpenHelper to allow SymmetricDS to connect to your device database
DatabaseName – Replace with your SQLite database name.
val DATABASE_NAME = "DatabaseName"
val DATABASE_VERSION = 1
class SDSDbHelper(context: Context) : SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(p0: SQLiteDatabase?) {
}
override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) {
}
}
Activity Code
- Endpoint – This is your SymmetricDS central node sync url (for simulator 10.0.2.2 resolves to the host machine).
- Auto Reload – If true this will send an initial data load to the device from the central for all configured tables.
- External ID – This is a unique name for each device
- Node Group ID – This is the group in SymmetricDS that provides all the configuration for replication (tables to replicate etc).
val symmetricdsOpenHelper = SDSDbHelper(this);
val HELPER_KEY = "SymmetricDSHelperKey";
SQLiteOpenHelperRegistry.register(HELPER_KEY, symmetricdsOpenHelper)
val intent = Intent(this, SymmetricService::class.java)
intent.putExtra(SymmetricService.INTENTKEY_SQLITEOPENHELPER_REGISTRY_KEY, HELPER_KEY)
intent.putExtra(
SymmetricService.INTENTKEY_REGISTRATION_URL,"http://10.0.2.2:31415/sync/server"
)
val properties = Properties()
properties.setProperty(ParameterConstants.AUTO_RELOAD, "true")
intent.putExtra(SymmetricService.INTENTKEY_PROPERTIES, properties)
intent.putExtra(SymmetricService.INTENTKEY_EXTERNAL_ID, "android-simulator")
intent.putExtra(SymmetricService.INTENTKEY_NODE_GROUP_ID, "client")
intent.putExtra(SymmetricService.INTENTKEY_START_IN_BACKGROUND, true)
this.startService(intent)
SymmetricDS Central
Now its time to allow this node into the sync scenario from the central SymmetricDS node.
View Devices Trying To Sync
The manage node screen will display all devices attempting to connect to the central
Accept Device
Allowing the device to register initiates the security handshake for all future communication and begins replication.
Validate in Android Logs
Next Steps
You are not set for mobile replication with Android using SymmetricDS. Read more about subsetting data to reduce how much your sending to each device.
Subsetting data with SymmetricDS