尝试了一切.此更新不起作用.没有错误或什么 - 它只是没有更新表.
void SetDisable (Integer ID, boolean action){
Integer s;
if (action==true) s = 0; else s = 1;
db.rawQuery("UPDATE sms SET disabled="+s+" WHERE id="+ID+"",null);
}
Run Code Online (Sandbox Code Playgroud)
这是我的表架构:
CREATE TABLE sms (id INTEGER PRIMARY KEY, fromhour INT, frommin INT, tohour INT, tomin INT, disabled INT);
sqlite>
Run Code Online (Sandbox Code Playgroud)
Sou*_*rma 11
试试这个:
db.execSQL("UPDATE sms SET disabled="+s+" WHERE id="+ID+"");
Run Code Online (Sandbox Code Playgroud)
返回表(游标)的SQL查询将使用rawQuery运行,而那些不返回表的SQL查询将使用execSQL运行
看到这个:
使用SQLiteDatabase类提供的更新方法很容易.
void SetDisable (Integer ID, boolean action){
Integer s;
if (action==true) s = 0; else s = 1;
ContentValues cv=new ContentValues();
cv.put(disabled, s);
String where = "id=?";
String[] whereArgs = {Integer.toString(ID)};
db.update(sms, cv, where , whereArgs);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6778 次 |
最近记录: |