how to save the history of specific column in sqlite db

Viewed 82

my app contain sqlite db, my question: is there a method or a way to save and view the history of a specific column if it has changed or updated ? my app is basically for input and output for items. everything is working fine but I want to keep track of the history of the quantity of the item and I cant figure it out the code of output an item :

boolean updateexistItemOutput(String itemname, String itemtype ,String itemsTypeOut, double outputQty, double total, double profit, double profitMultiple, double totalProfitSingle,
                          double totalProfitMultiple, String lastUpdated, String inOrOut, String notes) {
SQLiteDatabase sqLiteDatabase = getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(column_name, itemname);
contentValues.put(column_outputquantity, outputQty);
contentValues.put(column_itemsType,itemtype);
contentValues.put(column_total, total);
contentValues.put(column_profitSingle, profit);
contentValues.put(column_profitMultiple, profitMultiple);
contentValues.put(column_TotalprofitSingle, totalProfitSingle);
contentValues.put(column_TotalprofitMultiple, totalProfitMultiple);
contentValues.put(column_updateDate, lastUpdated);
contentValues.put(column_inOurOut, inOrOut);
contentValues.put(column_notes,notes);
contentValues.put(column_itemsTypeOut, itemsTypeOut);
return sqLiteDatabase.update(table_Name, contentValues, column_name + "=?", new String[]{itemname}) > 0;

}

1 Answers

I think the common way is create a new table History that record the data change.

Every time you change the data should insert a new record into the History table.

Related