0
私はSQLiteデータベースを動作させる際に問題が発生しており、私のコード以外のものかもしれません。 hereからサンプルSQLiteアプリをダウンロードしましたが、エミュレータや携帯電話では動作しません。あなたが見ているLogCatのエラーは次のとおりです。サンプルアプリケーションでもSQLiteが発行されます
何が起こっているのかについてご意見がありましたら、お知らせください。
03-04 00:48:26.472: E/Database(6653): Error inserting DeptID=3 DeptName=HR
03-04 00:48:26.472: E/Database(6653): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
03-04 00:48:26.472: E/Database(6653): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
03-04 00:48:26.472: E/Database(6653): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
03-04 00:48:26.472: E/Database(6653): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1582)
03-04 00:48:26.472: E/Database(6653): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.DatabaseHelper.InsertDepts(DatabaseHelper.java:144)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.DatabaseHelper.onCreate(DatabaseHelper.java:65)
03-04 00:48:26.472: E/Database(6653): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.DatabaseHelper.getEmployeeCount(DatabaseHelper.java:105)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.AddEmployee.onStart(AddEmployee.java:40)
03-04 00:48:26.472: E/Database(6653): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
03-04 00:48:26.472: E/Database(6653): at android.app.Activity.performStart(Activity.java:3791)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1491)
03-04 00:48:26.472: E/Database(6653): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
03-04 00:48:26.472: E/Database(6653): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
03-04 00:48:26.472: E/Database(6653): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:657)
03-04 00:48:26.472: E/Database(6653): at android.widget.TabHost.setCurrentTab(TabHost.java:329)
03-04 00:48:26.472: E/Database(6653): at android.widget.TabHost.addTab(TabHost.java:219)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.DatabaseDemo.SetupTabs(DatabaseDemo.java:85)
03-04 00:48:26.472: E/Database(6653): at mina.android.DatabaseDemo.DatabaseDemo.onCreate(DatabaseDemo.java:32)
03-04 00:48:26.472: E/Database(6653): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-04 00:48:26.472: E/Database(6653): at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 00:48:26.472: E/Database(6653): at android.os.Looper.loop(Looper.java:130)
03-04 00:48:26.472: E/Database(6653): at android.app.ActivityThread.main(ActivityThread.java:3688)
03-04 00:48:26.472: E/Database(6653): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 00:48:26.472: E/Database(6653): at java.lang.reflect.Method.invoke(Method.java:507)
03-04 00:48:26.472: E/Database(6653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
03-04 00:48:26.472: E/Database(6653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
03-04 00:48:26.472: E/Database(6653): at dalvik.system.NativeStart.main(Native Method)
03-04 00:48:26.925: W/PhoneWindow(6653): Previously focused view reported id 2131034112 during save, but can't be found during restore.