I got a problem with LoaderManager. I have some tables in sqlite database, and also have representation view, which get data from tables.
I also had implemented LoaderManager, exactly as in that excellent guide and it works perfectly for table.
But I want to update one table, and get updated result not from it, but from sqlite view, related to updated table. In this case LoaderManager, seems, not working (onLoadFinished callback does not fired)
My updated table schema:
CREATE TABLE [table_scan] (
[_id] INTEGER PRIMARY KEY AUTOINCREMENT,
[NR_ID] INTEGER NOT NULL,
[T_ID] INTEGER NOT NULL,
[Color_ID] INTEGER NOT NULL,
[R_ID] INTEGER NOT NULL,
[Barcode] TEXT NOT NULL,
[NumberSeat] INTEGER,
[Date] DATETIME NOT NULL DEFAULT(DATETIME('now', 'localtime')),
[Deleted] INTEGER NOT NULL DEFAULT '0',
[Status] INTEGER NOT NULL DEFAULT '0',
[Export] INTEGER NOT NULL DEFAULT '0');
My sqlite view:
CREATE VIEW [view_scan] AS SELECT _id, Barcode, Status, Deleted, NumberSeat,
goods_catalog.T_Articul, colors_catalog.Color_Name, sizes_catalog.R_Name
FROM table_scan
INNER JOIN goods_catalog ON goods_catalog.T_ID = table_scan.T_ID
INNER JOIN colors_catalog ON colors_catalog.Color_ID = table_scan.Color_ID
INNER JOIN sizes_catalog ON sizes_catalog.R_ID = table_scan.R_ID
WHERE Deleted = 0;
Found a workaround. Not very clean, but works:
Uris for LoaderManager init and for update data must be equals. So, we need to update view. We can create trigger for that.
First, modify view to get all needed columns:
Next, create trigger for view_scan:
Now, we can update data to view_scan instead of table_scan and LoaderManager works fine.