问题描述
我创建了一个SQL查询,以删除给定rowid的行。当我运行查询时,没有错误,但是,该行不会被删除。
AND NOT (business_desk ='D_ONE' AND FLOW = 'D1' and DEST_DESK = 'DELTA')
AND (business_desk !='D_ONE' AND FLOW != 'D1' and DEST_DESK != 'DELTA')
解决方法
尝试一下:
String query = "DELETE FROM " + TABLE_NAME + " WHERE rowid " + " = '" + id + "'";
db.execSQL(query);
但是我个人更喜欢这种方式:
if (db.delete(TABLE_NAME,rowid+ " = ?",new String[]{id}) != 0) {
Log.i("row","Has been deleted");
} else{
Log.i("row","Has not been deleted");
}
,
解决方案:我使用了vacuum功能来重新生成正确的rowId。我以前曾删除过rowId不存在的行。