我創建一個表是這樣的:錯誤插入一條記錄到由SQLite的一個表中的Android項目
DB_CREATE = "create table " + DB_TABLE + " (" +
"id" + " integer, " +
"title" + " text, " + "author" + " text, " +
"image" + " text, " + "time" + " text, " +
"detail" + " text);";
_db.execSQL(DB_CREATE);
這_db是參考SQLiteDatabase。我調用方法插入()如下:
ContentValues newValues = new ContentValues();
if(object instanceof NewsBean) {
newValues.put("id", ((NewsBean) object).getId());
newValues.put("title", ((NewsBean) object).getTitle());
newValues.put("author", ((NewsBean) object).getAuthor());
newValues.put("image", ((NewsBean) object).getImage());
newValues.put("time", ((NewsBean) object).getTime());
newValues.put("detail", ((NewsBean) object).getDetail());
return db.insert(DB_TABLE, null, newValues);
}
的問題是,在newValues元素不列爲表colomns。如何解決它?我不想改變桌子。
卸載您的應用程序並重新安裝。如果你還沒有升級數據庫,這將修復它。相反,您可以嘗試數據庫升級來重新實例化表。這當然假設您的應用程序在添加數據庫功能之前正在工作,並且您正在調用它。你可以發佈你的堆棧跟蹤? – AedonEtLIRA 2012-03-19 14:27:00
請不要列爲表格欄目,這是什麼意思?你的意思是這個命令嗎? – KarlKarlsom 2012-03-19 14:27:59
是的,訂單不像桌子那樣。 – Androidist 2012-03-19 14:44:37