Solution 1 :
You need to mark your transaction as “clean” by calling db.setTransactionSuccessful()
before calling db.endTransaction()
. If you do not set your transaction as successful, your changes are immediately rolled back as soon as the transaction is ended (as it assumes there was an error).
For more information, see the SQLiteDatabase documentation here
Problem :
*TABLE NOT UPDATING*****HOW TO SOLVE THE PROBLEM
public String getElapsedTime(String session_id, String time) {
db = this.getWritableDatabase();
db.beginTransaction();
db.setTransactionSuccessful();
Log.d("CHINMAY", "Update in Sql get ElapsedTime " + session_id + "n" + time);
ContentValues cv = new ContentValues();
cv.put(ELAPSED_TIME, time);
db.update(TABLE_SESSION_TEST, cv, "session_id=?", new String[]{session_id});
db.endTransaction();
return "Checking Update";
}
Comments
Comment posted by Chinmay Moharana
I didn’t understand how to clean.
Comment posted by Eric Bachhuber
db.update(TABLE_SESSION_TEST, cv, “session_id=?”, new String[]{session_id}); db.setTransactionSuccessful(); db.endTransaction();
Comment posted by Eric Bachhuber
db.update() returns an integer of how many rows have been updated. When that code runs, does db.update() return a 0 or a 1? If it’s a 0, check your data and query to make sure it’s correct.
Comment posted by Chinmay Moharana
i changed the code and return boolean value output is coming toast.message as true.But database i checked is not displaying.
Comment posted by Chinmay Moharana
Actually i tried the code is updated after some time. But when i move to next activity the value is not coming immediately