と という 2 つのアクティビティがMainActivity
ありFavorites
ます。ではMainActivity
、次のようなものがあります。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//function to insert data to database
insertData();
}
アクティビティMainActivity
にリンクするためのリンクがあります。Favorites
しかし、お気に入りから MainActivity に戻る Up Navigation ボタンをクリックすると、アプリが閉じていました。
onCreate
データの挿入をイベントにするのは理想的ですか?
助けてください。ありがとうございました。
ログは次のとおりです。
11-08 15:50:14.848: E/SQLiteLog(8746): (5) database is locked
11-08 15:50:14.865: E/SQLiteDatabase(8746): Failed to open database '/data/data/example.pangasinantranslator/databases/dbTrans'.
11-08 15:50:14.865: E/SQLiteDatabase(8746): android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:627)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:313)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:287)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:215)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:884)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at example.pangasinantranslator.MySQLiteHelper.addWord(MySQLiteHelper.java:46)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at example.pangasinantranslator.MainActivity.readFile(MainActivity.java:240)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at example.pangasinantranslator.MainActivity.onCreate(MainActivity.java:56)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.Activity.performCreate(Activity.java:5020)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ActivityThread.access$600(ActivityThread.java:181)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.os.Looper.loop(Looper.java:153)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at android.app.ActivityThread.main(ActivityThread.java:5042)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at java.lang.reflect.Method.invokeNative(Native Method)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at java.lang.reflect.Method.invoke(Method.java:511)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-08 15:50:14.865: E/SQLiteDatabase(8746): at dalvik.system.NativeStart.main(Native Method)
11-08 15:50:14.865: D/Here is error(8746): android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
11-08 15:50:14.865: D/Insert:(8746): Inserting ..