SQLite 側に関する別の Java の質問です。
アプリを実行しましたが、挿入されたデータを追加するまでは問題ありません。「12-31 22:54:51.133: I/Database(273): sqlite returned: error code = 1, msg = no such table: peopleTable」のログ キャットにエラーが表示されます。これは明らかに、挿入メソッドを使用してDBに追加できないという事実につながります。
DB の名前を変更しようとしましたが、テーブルの create ステートメントや onCreate/Upgrade メソッドに問題はありません。
コードは次のとおりです。
コード:
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" +
KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " TEXT NOT NULL, " +
KEY_HOTNESS + "TEXT NOT NULL);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXCISTS" + DATABASE_TABLE);
onCreate(db);
}
そしてlogcat:
12-31 22:54:51.133: I/Database(273): sqlite returned: error code = 1, msg = no such table: peopleTable
12-31 22:54:51.158: E/Database(273): Error inserting persons_hotness=5 persons_name=F
12-31 22:54:51.158: E/Database(273): android.database.sqlite.SQLiteException: no such table: peopleTable: , while compiling: INSERT INTO peopleTable(persons_hotness, persons_name) VALUES(?, ?);
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
12-31 22:54:51.158: E/Database(273): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
12-31 22:54:51.158: E/Database(273): at com.example.sqliteexample.HotOrNot.createEntry(HotOrNot.java:174)
12-31 22:54:51.158: E/Database(273): at com.example.sqliteexample.SQLiteExample.onClick(SQLiteExample.java:57)
12-31 22:54:51.158: E/Database(273): at android.view.View.performClick(View.java:2408)
12-31 22:54:51.158: E/Database(273): at android.view.View$PerformClick.run(View.java:8816)
12-31 22:54:51.158: E/Database(273): at android.os.Handler.handleCallback(Handler.java:587)
12-31 22:54:51.158: E/Database(273): at android.os.Handler.dispatchMessage(Handler.java:92)
12-31 22:54:51.158: E/Database(273): at android.os.Looper.loop(Looper.java:123)
12-31 22:54:51.158: E/Database(273): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-31 22:54:51.158: E/Database(273): at java.lang.reflect.Method.invokeNative(Native Method)
12-31 22:54:51.158: E/Database(273): at java.lang.reflect.Method.invoke(Method.java:521)
12-31 22:54:51.158: E/Database(273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-31 22:54:51.158: E/Database(273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-31 22:54:51.158: E/Database(273): at dalvik.system.NativeStart.main(Native Method)
12-31 23:17:38.508: W/KeyCharacterMap(273): No keyboard for id 0
12-31 23:17:38.508: W/KeyCharacterMap(273): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
12-31 23:17:40.238: D/AndroidRuntime(273): Shutting down VM
12-31 23:17:40.238: W/dalvikvm(273): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-31 23:17:40.259: E/AndroidRuntime(273): FATAL EXCEPTION: main
12-31 23:17:40.259: E/AndroidRuntime(273): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.sqliteexample.SQLView }
12-31 23:17:40.259: E/AndroidRuntime(273): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.app.Activity.startActivityForResult(Activity.java:2817)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.app.Activity.startActivity(Activity.java:2923)
12-31 23:17:40.259: E/AndroidRuntime(273): at com.example.sqliteexample.SQLiteExample.onClick(SQLiteExample.java:94)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.view.View.performClick(View.java:2408)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.view.View$PerformClick.run(View.java:8816)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.os.Handler.handleCallback(Handler.java:587)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.os.Handler.dispatchMessage(Handler.java:92)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.os.Looper.loop(Looper.java:123)
12-31 23:17:40.259: E/AndroidRuntime(273): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-31 23:17:40.259: E/AndroidRuntime(273): at java.lang.reflect.Method.invokeNative(Native Method)
12-31 23:17:40.259: E/AndroidRuntime(273): at java.lang.reflect.Method.invoke(Method.java:521)
12-31 23:17:40.259: E/AndroidRuntime(273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-31 23:17:40.259: E/AndroidRuntime(273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-31 23:17:40.259: E/AndroidRuntime(273): at dalvik.system.NativeStart.main(Native Method)