简体   繁体   中英

SQLITE Database not updating the TABLE

*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";
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM