我必须删除TABLE_LOCATION中的某些行。我正在使用以下代码,但并未删除。任何人都知道解决方案。
public void deleteData(String favouriteOrNot, String vaType) {
SQLiteDatabase db = this.getReadableDatabase();
String deleteQuery = "DELETE FROM " + TABLE_LOCATION + " WHERE " + this.FavouriteOrNot + "='" + favouriteOrNot + "' AND " + this.VaType + "='" + vaType + "';";
db.execSQL(deleteQuery);
}
答案 0 :(得分:1)
尝试这种方式
用于删除整个表格
public int DELETE_TABLE(String tableName){
return myDataBase.delete(tableName, null, null);
}
或
用于删除多个条目
public int DELETE_TABLE_WITH_SELECTION(String tableName, String selection){
return myDataBase.delete(tableName, selection, null);
}
这里myDataBase
是SQLiteDatabase。
selection = this.FavouriteOrNot + "='" + favouriteOrNot + "' AND " + this.VaType + "='" + vaType + "'";