クエリを実行するメソッドを呼び出すため、この例外が発生します。問題は、列が存在しないことを示しているということです。実際、名前を変更して、データベースを再度作成しました。不思議なことに、呼び出しはquery()の "Columns []"引数の列を私に尋ね続けますが、それを追加すると、それは私に再びそれを尋ね続けます。理解できない。列の名前は「bookmark_title」に変更され、「title」に変更されました。ヒントはありますか。どうもありがとうございます。
メソッド呼び出し:
public Cursor bookmarksURLs(int user_id){
Cursor result;
String bookmarks="bookmarks";
String [] columns={"_id","bookmark_url","title","bookmark_title","fk_user_bookmark"};
String where = "fk_user_bookmark = 1";
try {
result = db.query(bookmarks,columns,where,null,null,null,null);
return result;
} catch (SQLiteException e){
Log.v("Query","Error en el query");
e.printStackTrace();
}
return null;
}
「bookmark_title」を含めずにログに記録する
10-22 17:42:34.604: INFO/ActivityManager(58): Starting activity: Intent { cmp=example.android.com/.BookmarkList }
10-22 17:42:34.824: INFO/System.out(335): Base de datos abierta
10-22 17:42:34.835: DEBUG/AndroidRuntime(335): Shutting down VM
10-22 17:42:34.835: WARN/dalvikvm(335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): FATAL EXCEPTION: main
10-22 17:42:34.855: ERROR/AndroidRuntime(335): java.lang.RuntimeException: Unable to start activity ComponentInfo{example.android.com/example.android.com.BookmarkList}: java.lang.IllegalArgumentException: column 'bookmark_title' does not exist
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:521)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): Caused by: java.lang.IllegalArgumentException: column 'bookmark_title' does not exist
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:87)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at example.android.com.BookmarkList.onCreate(BookmarkList.java:22)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-22 17:42:34.855: ERROR/AndroidRuntime(335): ... 11 more
10-22 17:42:34.885: WARN/ActivityManager(58): Force finishing activity example.android.com/.BookmarkList
10-22 17:42:34.885: WARN/ActivityManager(58): Force finishing activity example.android.com/.AndroidBoorkmarksActivity
10-22 17:42:35.384: WARN/ActivityManager(58): Activity pause timeout for HistoryRecord{4508e9e0 example.android.com/.BookmarkList}
10-22 17:42:45.746: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{44fd28a8 example.android.com/.AndroidBoorkmarksActivity}
10-22 17:42:45.765: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{4508e9e0 example.android.com/.BookmarkList}
「bookmark_title」を含めてログに記録する
10-22 17:51:57.455: WARN/System.err(528): android.database.sqlite.SQLiteException: no such column: bookmark_title: , while compiling: SELECT _id, bookmark_url, title, bookmark_title, fk_user_bookmark FROM bookmarks WHERE fk_user_bookmark = 1
10-22 17:51:57.465: WARN/System.err(528): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
10-22 17:51:57.465: WARN/System.err(528): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
10-22 17:51:57.465: WARN/System.err(528): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
10-22 17:51:57.465: WARN/System.err(528): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
10-22 17:51:57.475: WARN/System.err(528): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
10-22 17:51:57.475: WARN/System.err(528): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
10-22 17:51:57.475: WARN/System.err(528): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
10-22 17:51:57.485: WARN/System.err(528): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
10-22 17:51:57.485: WARN/System.err(528): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
10-22 17:51:57.495: WARN/System.err(528): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
10-22 17:51:57.495: WARN/System.err(528): at example.android.com.DatabaseHandler.bookmarksURLs(DatabaseHandler.java:53)
10-22 17:51:57.495: WARN/System.err(528): at example.android.com.BookmarkList.onCreate(BookmarkList.java:17)
10-22 17:51:57.505: WARN/System.err(528): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-22 17:51:57.505: WARN/System.err(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-22 17:51:57.505: WARN/System.err(528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-22 17:51:57.505: WARN/System.err(528): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-22 17:51:57.515: WARN/System.err(528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-22 17:51:57.515: WARN/System.err(528): at android.os.Handler.dispatchMessage(Handler.java:99)
10-22 17:51:57.515: WARN/System.err(528): at android.os.Looper.loop(Looper.java:123)
10-22 17:51:57.515: WARN/System.err(528): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-22 17:51:57.525: WARN/System.err(528): at java.lang.reflect.Method.invokeNative(Native Method)
10-22 17:51:57.525: WARN/System.err(528): at java.lang.reflect.Method.invoke(Method.java:521)
10-22 17:51:57.525: WARN/System.err(528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-22 17:51:57.525: WARN/System.err(528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-22 17:51:57.525: WARN/System.err(528): at dalvik.system.NativeStart.main(Native Method)