A little late, but what the hell, you can also add a bunch TRIGGERto your tables and save the change table, as shown below. The last modification is recorded with the type and date + time in the table modifications. Creating TRIGGERlike this can be easily done by a simple method and called for every table created in yourSQLiteOpenHelper
CREATE TABLE table1 (
_id INTEGER PRIMARY KEY AUTOINCREMENT,
text1 TEXT,
text2 TEXT
);
CREATE TABLE table2 (
_id INTEGER PRIMARY KEY AUTOINCREMENT,
text1 TEXT,
int1 INTEGER
);
CREATE TABLE modifications (
table_name TEXT NOT NULL PRIMARY KEY ON CONFLICT REPLACE,
action TEXT NOT NULL,
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TRIGGER IF NOT EXISTS table1_ondelete AFTER DELETE ON table1
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table1','DELETE');
END;
CREATE TRIGGER IF NOT EXISTS table2_ondelete AFTER DELETE ON table2
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table2','DELETE');
END;
CREATE TRIGGER IF NOT EXISTS table1_onupdate AFTER UPDATE ON table1
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table1','UPDATE');
END;
CREATE TRIGGER IF NOT EXISTS table2_onupdate AFTER UPDATE ON table2
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table2','UPDATE');
END;
CREATE TRIGGER IF NOT EXISTS table1_oninsert AFTER INSERT ON table1
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table1','INSERT');
END;
CREATE TRIGGER IF NOT EXISTS table2_oninsert AFTER INSERT ON table2
BEGIN
INSERT INTO modifications (table_name, action) VALUES ('table2','INSERT');
END;
source
share