How to best prepare an offline database app for future synchronization with an online server


I have a small Android app written in Kotlin using Jetpack Compose. It currently stores data locally using the Room database which is enough for now. However, I might want to expand it to store data on an online server as well in the future, i.e. the data would still be stored locally and synchronized with an online server whenever Internet connection would be available. Is there anything I should consider now to make such synchronization easier/possible in the future?

1
Feb 20 at 5:11 PM
User AvatarJoyce Opio
#android#database#data-synchronization

Accepted Answer

Room isn't a database. It's a library for generating SQL querries. The db used in Android is SQLite. And really my suggestion would be- don't use SQLite. There are dbs like firebase, couchbase, etc which have the syncing functionality built in. Use one of them. Because writing the syncing functionality can be a true nightmare if you need full bidirectional sync. Ever heard the old joke that "the only hard problems in CS are cache coherency and naming things"? Syncing is literally cache coherency, one of the hardest things to do right.

User AvatarGabe Sechan
Feb 20 at 5:28 PM
0