【发布时间】:2016-08-06 03:43:44
【问题描述】:
我参考了以下页面,但我的问题仍然没有解决,
Android sqlite update table always return 0、SQLite in Android How to update a specific row、Android SQLite update row not working、Update Function in android SQLite is not working 和 SQLiteDatabase update not working?
我有一个 sqlite 数据库,因为 QUESTIONS(ID,QUES,ANS),ID 是主键。当我尝试使用以下代码更新值时,数据库中不会发生任何变化。
SQLiteDatabase db = null;
ContentValues values = new ContentValues();
values.put("QUES","New title");
values.put("ANS","Answer" );
long k= db.update("QUESTIONS",values,"ID=2",null);
Log.d("Success",""+k);
k的值为1,数据库没有变化。我也尝试过
long k= db.update("QUESTIONS",values,null,null);
但是没有用。
【问题讨论】: