I am building an android app that has a mobile, wear and shared module. It is an app that stores data with my SampleObject to the SQLiteDatabase.
SampleObject{
long ID; // Primary key, autoincrement
Date date;
String text;
}
All methods regarding users list of SampleObjects are in the shared module. Both mobile and wear can insert, edit and delete objects.
Is there a way to use "shared" database or do I have to use separate DBs for mobile and wear and on wear connect to compare them and merge?
If I have to use separate DBs, what is the best way (and when) to compare them (there can be some deleted items that are still contained in one of DBs)?
There is no shared SQLite database. If your shared data requirements are simple enough to store in SharedPreferences
, you could use PrefSyncService, but I've never seen a similar library for syncing SQL data.
In general, though, I would think that the question of when to sync them is going to be driven by your own app logic; there's no "one size fits all" answer for that.