简体   繁体   English

SQLITE 数据库不更新表

[英]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() .你需要通过调用来标记您的交易为“干净” db.setTransactionSuccessful()调用之前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有关更多信息,请参阅此处SQLiteDatabase 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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