Update Function in android SQLite is not working

前端 未结 2 411
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 04:37

In my application I need to add and edit data to the SQLite database. When I do update data function app do not give any errors but my database wont update. Here is my Updat

相关标签:
2条回答
  • 2021-01-06 05:19

    Your function returns 1; that's not ok... it should return ContentValues cv

    return db.update(DATABASE_TABLE, cv, KEY_ROWID+"="+rowId, null)
    
    0 讨论(0)
  • 2021-01-06 05:20

    There may be a problem in the update statement, Try:

     long i = myDB.update(DATABASE_TABLE, cv, KEY_ROWID + "=?", new String[]{rowid});
    
     if(i>0)
         return 1;  // 1 for successful
     else
         return 0;  // 0 for unsuccessful
    

    And yes go through the public int update (String table, ContentValues values, String whereClause, String[] whereArgs) function.

    0 讨论(0)
提交回复
热议问题