我有一个Listview,从sqlite数据库填充。数据库创建时使用:
egrohDB.execSQL("CREATE TABLE IF NOT EXISTS " + EGROH_DB_TABLE_ITEMS +
" (ident integer primary key AUTOINCREMENT, " +
"id integer(15), " +
...
要从数据库中获取数据,我使用rawQueries
并插入我正在使用InsertHelper
的数据。我在表格中添加了一行。现在我得到一个IllegalArgumentException
,那个mit id行无效。
06-02 17:48:24.340: E/AndroidRuntime(23200): FATAL EXCEPTION: main
06-02 17:48:24.340: E/AndroidRuntime(23200): java.lang.IllegalArgumentException: column 'id' is invalid
06-02 17:48:24.340: E/AndroidRuntime(23200): at android.database.DatabaseUtils$InsertHelper.getColumnIndex(DatabaseUtils.java:1078)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.y5apps.DatabaseController.insertData(DatabaseController.java:273)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.y5apps.EgrohCatalogue.parseData(EgrohCatalogue.java:149)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.y5apps.EgrohCatalogue$3.onClick(EgrohCatalogue.java:319)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
06-02 17:48:24.340: E/AndroidRuntime(23200): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 17:48:24.340: E/AndroidRuntime(23200): at android.os.Looper.loop(Looper.java:137)
06-02 17:48:24.340: E/AndroidRuntime(23200): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-02 17:48:24.340: E/AndroidRuntime(23200): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 17:48:24.340: E/AndroidRuntime(23200): at java.lang.reflect.Method.invoke(Method.java:511)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-02 17:48:24.340: E/AndroidRuntime(23200): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-02 17:48:24.340: E/AndroidRuntime(23200): at dalvik.system.NativeStart.main(Native Method)
错误显示在此行:
final int id_c = ih.getColumnIndex("id");
我不知道这个例外意味着什么。怎么办?
答案 0 :(得分:0)
您创建了列“id”,并且要求列“item_id”...不在您显示的代码中但在某处......
它在你的插页中。