Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
We don't support cross-process invalidations yet.
se...@gmail.com <se...@gmail.com> #3
At least , add a "refresh all observables" function to alpha4 ? i am trying to implement it by myself with your InvalidationTracker class
se...@gmail.com <se...@gmail.com> #4
Okey, I made it and created a method to invalidate all observables below;
private void refreshAllLiveData() {
AppDataBase YOUR_DATABASE_WHICH_YOU_BUILD = .....
SupportSQLiteDatabase writableDatabase = YOUR_DATABASE_WHICH_YOU_BUILD.getOpenHelper().getWritableDatabase();
//get the database count;
Cursor cursor = writableDatabase.query("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name != 'android_metadata' AND name != 'room_master_table';");
int tableCount = 0;
while(cursor.moveToNext()) {
tableCount = cursor.getInt(0);
}
for (int i = 0; i < tableCount; i++) {
//update version table with the incremented count because room modification log stores tables with ids instead of names
writableDatabase.execSQL("INSERT OR REPLACE INTO room_table_modification_log VALUES(null, "+(i)+")");
}
YOUR_DATABASE_WHICH_YOU_BUILD.getInvalidationTracker().refreshVersionsAsync();
}
-----
This is a workaroud for refreshing all live datas, I still prefer to use a proper API you implemented.
Thanx
private void refreshAllLiveData() {
AppDataBase YOUR_DATABASE_WHICH_YOU_BUILD = .....
SupportSQLiteDatabase writableDatabase = YOUR_DATABASE_WHICH_YOU_BUILD.getOpenHelper().getWritableDatabase();
//get the database count;
Cursor cursor = writableDatabase.query("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name != 'android_metadata' AND name != 'room_master_table';");
int tableCount = 0;
while(cursor.moveToNext()) {
tableCount = cursor.getInt(0);
}
for (int i = 0; i < tableCount; i++) {
//update version table with the incremented count because room modification log stores tables with ids instead of names
writableDatabase.execSQL("INSERT OR REPLACE INTO room_table_modification_log VALUES(null, "+(i)+")");
}
YOUR_DATABASE_WHICH_YOU_BUILD.getInvalidationTracker().refreshVersionsAsync();
}
-----
This is a workaroud for refreshing all live datas, I still prefer to use a proper API you implemented.
Thanx
yb...@google.com <yb...@google.com>
sh...@google.com <sh...@google.com>
da...@google.com <da...@google.com> #5
Cross process invalidation is now support in Room 2.1.0 with the enableMultiInstanceInvalidation() API.
Description
Version used: 1.0.0-alpha3
Devices/Android versions reproduced on: Nexus 5X
- Sample project to trigger the issue.
Create 2 projetcs using same sharedUserId
make them to create RoomDatabase in same file location
use live data to observe changes
change data from application A and observe it on Application B
--Fail (can not be observed)--
- A screenrecord or screenshots showing the issue (if UI related).
N/A
This issue is not about sharedUserIds I get it. If you are using a database from SDcard and working on it with different applications, you will not be notified with changes on each application. LiveData on Room invalidates compute of changes with beginTransaction so if another application changes a table you observed, Room will not change in memory application database table, so second application will not be notified.
My suggestion to solve this issue is; create a valid, "not in memory" version table and create a hash instead of integer version_number for each table and track the changes on this hash.