这是错误:
09-27 12:47:39.155: WARN/System.err(10899): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
09-27 12:47:39.155: WARN/System.err(10899): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
09-27 12:47:39.155: WARN/System.err(10899): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
09-27 12:47:39.155: WARN/System.err(10899): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1809)
09-27 12:47:39.165: WARN/System.err(10899): at de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1279)
09-27 12:47:39.165: WARN/System.err(10899): at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:178)
09-27 12:47:39.165: WARN/System.err(10899): at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 12:47:39.165: WARN/System.err(10899): at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 12:47:39.165: WARN/System.err(10899): at java.lang.Thread.run(Thread.java:1019)
以下是代码:
this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET " +
CMSConstants.ID + "= ?, " +
CMSConstants.TITLE + " = ?, " +
CMSConstants.IS_PAGE + " = ?, " +
CMSConstants.IS_HIDDEN + " = ?, " +
CMSConstants.ITEM_TYPE + " = ?, " +
CMSConstants.ORDER_INDEX + " = ?, " +
CMSConstants.SECTION_ID + " = ?, " +
CMSConstants.TABLE_SECTION_NAME + " = ?, " +
CMSConstants.TABLE_SECTION_ID + " = ?, " +
CMSConstants.IMAGE1_FILE + " = ?, " +
CMSConstants.IMAGE1_CAPTION + " = ?, " +
CMSConstants.IMAGE1_DISPLAY_IN_GALLERY + " = ?, " +
CMSConstants.CATEGORY1 + " = ?, " +
CMSConstants.CATEGORY2 + " = ?, " +
CMSConstants.GEO_LONGITUDE + " = ?, " +
CMSConstants.GEO_LATITUDE + " = ?, " +
CMSConstants.DESCRIPTION + " = ?, " +
CMSConstants.KEYWORDS + " = ?, " +
CMSConstants.BLOCKWORDS + " = ?, " +
CMSConstants.CLEAN_NAME + " = ?, " +
CMSConstants.ADDITIONAL_FIELD1_NAME + " = ?, " +
CMSConstants.ADDITIONAL_FIELD1_VALUE + " = ?, " +
CMSConstants.ADDITIONAL_FIELD2_NAME + " = ?, " +
CMSConstants.ADDITIONAL_FIELD2_VALUE + " = ?, " +
CMSConstants.ADDITIONAL_FIELD3_NAME + " = ?, " +
CMSConstants.ADDITIONAL_FIELD3_VALUE + " = ?, " +
CMSConstants.ADDITIONAL_FIELD4_NAME + " = ?, " +
CMSConstants.ADDITIONAL_FIELD4_VALUE + " = ?, " +
CMSConstants.ADDRESS_LINE1 + " = ?, " +
CMSConstants.ADDRESS_LINE2 + " = ?, " +
CMSConstants.ADDRESS_LINE3 + " = ?, " +
CMSConstants.ADDRESS_LINE4 + " = ?, " +
CMSConstants.ADDRESS_LINE5 + " = ?, " +
CMSConstants.ADDRESS_POSTCODE + " = ?, " +
CMSConstants.CONTACT_EMAIL + " = ?, " +
CMSConstants.CONTACT_EMAIL_DISPLAY + " = ?, " +
CMSConstants.CONTACT_EMAIL_SUBJECT + " = ?, " +
CMSConstants.CONTACT_TEL + " = ?, " +
CMSConstants.CONTACT_TEL_DISPLAY + " = ?, " +
CMSConstants.CONTACT_WEB + " = ?, " +
CMSConstants.CONTACT_WEB_DISPLAY + " = ?, " +
CMSConstants.MODIFICATION_DATE + " = ?, " +
CMSConstants.PAGE_HEADER + " = ?"
, bindArgs);
和bindArgs:
String[] bindArgs = {
(String) item.get(CMSConstants.ID),
(String) item.get(CMSConstants.TITLE),
(String) item.get(CMSConstants.IS_PAGE),
(String) item.get(CMSConstants.IS_HIDDEN),
(String) item.get(CMSConstants.ITEM_TYPE),
(String) item.get(CMSConstants.ORDER_INDEX),
(String) item.get(CMSConstants.SECTION_ID),
"",
"",
(String) item.get(CMSConstants.IMAGE1_FILE),
(String) item.get(CMSConstants.IMAGE1_CAPTION),
(String) item.get(CMSConstants.IMAGE1_DISPLAY_IN_GALLERY),
(String) item.get(CMSConstants.CATEGORY1),
(String) item.get(CMSConstants.CATEGORY2),
(String) item.get(CMSConstants.GEO_LONGITUDE),
(String) item.get(CMSConstants.GEO_LATITUDE),
(String) item.get(CMSConstants.DESCRIPTION),
(String) item.get(CMSConstants.KEYWORDS),
(String) item.get(CMSConstants.BLOCKWORDS),
(String) item.get(CMSConstants.CLEAN_NAME),
(String) item.get(CMSConstants.ADDITIONAL_FIELD1_NAME),
(String) item.get(CMSConstants.ADDITIONAL_FIELD1_VALUE),
(String) item.get(CMSConstants.ADDITIONAL_FIELD2_NAME),
(String) item.get(CMSConstants.ADDITIONAL_FIELD2_VALUE),
(String) item.get(CMSConstants.ADDITIONAL_FIELD3_NAME),
(String) item.get(CMSConstants.ADDITIONAL_FIELD3_VALUE),
(String) item.get(CMSConstants.ADDITIONAL_FIELD4_NAME),
(String) item.get(CMSConstants.ADDITIONAL_FIELD4_VALUE),
(String) item.get(CMSConstants.ADDRESS_LINE1),
(String) item.get(CMSConstants.ADDRESS_LINE2),
(String) item.get(CMSConstants.ADDRESS_LINE3),
(String) item.get(CMSConstants.ADDRESS_LINE4),
(String) item.get(CMSConstants.ADDRESS_LINE5),
(String) item.get(CMSConstants.ADDRESS_POSTCODE),
(String) item.get(CMSConstants.CONTACT_EMAIL),
(String) item.get(CMSConstants.CONTACT_EMAIL_DISPLAY),
(String) item.get(CMSConstants.CONTACT_EMAIL_SUBJECT),
(String) item.get(CMSConstants.CONTACT_TEL),
(String) item.get(CMSConstants.CONTACT_TEL_DISPLAY),
(String) item.get(CMSConstants.CONTACT_WEB),
(String) item.get(CMSConstants.CONTACT_WEB_DISPLAY),
(String) item.get(CMSConstants.MODIFICATION_DATE),
(String) item.get(CMSConstants.PAGE_HEADER)
};
所以有人知道我为什么会失败吗?
感谢名单 newone
答案 0 :(得分:1)
您缺少WHERE
子句,当您更新任何内容时,您必须指向要更新的位置