Hy!從SQLite中刪除
我總是得到e sql錯誤。我登錄已選定項的ID,然後我想從ListView中刪除它,然後從數據庫中
我的代碼:
public boolean onItemLongClick(final AdapterView<?> arg0, final View arg1,
final int arg2, long arg3) {
final Pizza pizza = (Pizza)arg0.getItemAtPosition(arg2);
Log.e("xxx",String.valueOf(pizza.id));
AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
builder.setMessage("Are you sure you to delete " + pizza.title + "?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
aa.notifyDataSetChanged();
list.remove(pizza);
aa = new CustomAdapter(Main.this, R.layout.customlistitem,list);
lv.setAdapter(aa);
myDB = Main.this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
myDB.execSQL("DELETE FROM "+MY_DB_TABLE+ " WHERE ID="+pizza.id);
}
登錄:
xxx是1這樣的標識披薩是1
10-03 09:23:13.135: ERROR/AndroidRuntime(640): android.database.sqlite.SQLiteException: no such column: ID: DELETE FROM Pizza WHERE ID=1