0
我的代碼:的Android的SQLite中刪除一行
public void droptablecontents(String category)
{
SQLiteDatabase db = this.getWritableDatabase();
String query = "DELETE FROM " + Table_Name + " WHERE " + KEY_CAT + "=" + category;
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
cursor.close();
}
我的表的創建語句:
"CREATE TABLE IF NOT EXISTS " + Table_Name + "(" + KEY_NOTE + " TEXT, " + KEY_CAT + " TEXT" + ")"
我的日誌貓錯誤:
android.database.sqlite.SQLiteException: no such column: Ideas (code 1): , while compiling: DELETE FROM Cats WHERE cat=Ideas
但爲什麼它尋找一個列命名爲'想法'?我正在嘗試在KEY_CAT列中搜索值'Ideas'。
'String [] params = new String [] {contact_no}; Cursor c = db.rawQuery(「DELETE FROM + Table_Name +」WHERE「+ KEY_CAT +」=?「, params);' –
**」從「+ Table_Name +」中刪除其中「+ KEY_CAT +」(「 +類別+「)」** 試試這個查詢 –