【发布时间】:2012-03-19 14:24:33
【问题描述】:
我创建一个这样的表:
DB_CREATE = "create table " + DB_TABLE + " (" +
"id" + " integer, " +
"title" + " text, " + "author" + " text, " +
"image" + " text, " + "time" + " text, " +
"detail" + " text);";
_db.execSQL(DB_CREATE);
哪个 _db 是对 SQLiteDatabase 的引用。我调用方法 insert() 如下:
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 中的元素没有作为表格列列出。如何解决?我不想换桌子。
【问题讨论】:
-
卸载您的应用并重新安装。如果您还没有升级数据库,这将解决它。相反,您可以尝试升级数据库以重新实例化该表。这当然是假设您的应用程序在您添加数据库功能之前正在运行并且您正在调用它。你能发布你的堆栈跟踪吗?
-
不作为表格列列出是什么意思?你是说订单吗?
-
是的,顺序和表格不一样。
-
感谢@AedonEtLIRA。我照你说的做,关于插入方法的错误消失了。然而,另一个问题出现了。很抱歉,我无法发布堆栈跟踪。怎么样?