0

私のAndroidアプリは電話のSQLiteDatabaseを利用しています. アプリのある時点でクラッシュすると、データベースが永久にロックされているため、突然多くのページ/フラグメントが機能しなくなるようです。

他の機能へのアクセスを再開できるように、手動でロックを解除/問題を解決する方法はありますか? 同じコードが他の友人の電話でも機能するため、デバッグを再度続行するには、自分の電話でデータベースのロックを手動で解除する必要があると思います。

以下は私の(編集済み:FULL)logcatです。

02-08 11:15:34.880: E/SqliteDatabaseCpp(10363): sqlite3_exec - Failed to set synchronous mode = 1(Normal) 
02-08 11:15:34.895: E/SQLiteDatabase(10363): Failed to open the database. closing it.
02-08 11:15:34.895: E/SQLiteDatabase(10363): android.database.sqlite.SQLiteDatabaseLockedException: database is locked
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1132)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1083)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1170)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:844)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:228)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at com.sqlite.database.PlaceDataSource.open(PlaceDataSource.java:26)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at com.activities.TravelogueListBaseAdapter.getView(TravelogueListBaseAdapter.java:163)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.AbsListView.obtainView(AbsListView.java:2197)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.ListView.onMeasure(ListView.java:1155)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:670)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1027)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:565)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at shared.ui.actionscontentview.ActionsContentView.onMeasure(ActionsContentView.java:259)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:822)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2257)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1240)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2628)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.os.Looper.loop(Looper.java:137)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at android.app.ActivityThread.main(ActivityThread.java:4511)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at java.lang.reflect.Method.invokeNative(Native Method)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at   java.lang.reflect.Method.invoke(Method.java:511)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
02-08 11:15:34.895: E/SQLiteDatabase(10363):    at dalvik.system.NativeStart.main(Native Method)
02-08 11:15:34.900: E/AndroidRuntime(10363): FATAL EXCEPTION: main
02-08 11:15:34.900: E/AndroidRuntime(10363): android.database.sqlite.SQLiteDatabaseLockedException: database is locked
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1132)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1083)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1170)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:844)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:228)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at com.sqlite.database.PlaceDataSource.open(PlaceDataSource.java:26)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at com.activities.TravelogueListBaseAdapter.getView(TravelogueListBaseAdapter.java:163)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.AbsListView.obtainView(AbsListView.java:2197)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.ListView.onMeasure(ListView.java:1155)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:670)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1027)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:565)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at shared.ui.actionscontentview.ActionsContentView.onMeasure(ActionsContentView.java:259)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:822)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2257)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.View.measure(View.java:12929)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1240)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2628)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.os.Looper.loop(Looper.java:137)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at android.app.ActivityThread.main(ActivityThread.java:4511)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at java.lang.reflect.Method.invokeNative(Native Method)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at java.lang.reflect.Method.invoke(Method.java:511)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
02-08 11:15:34.900: E/AndroidRuntime(10363):    at dalvik.system.NativeStart.main(Native Method)
02-08 11:15:34.920: E/android.os.Debug(1981): !@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error
02-08 11:15:35.420: E/lights(1981): write_int: path 
4

2 に答える 2

1

これが発生する理由は、データベースへの接続を一度に 1 つしか開くことができないためです。Db接続を閉じていないか、書き込みしようとしているときにスレッドがすでにDbに書き込んでいると思います。

1 つの SQLOpenHelper から db にアクセスすることをお勧めします (この例を参照してください)。

于 2013-02-08T03:02:38.093 に答える
1

アプリケーションを閉じる (またはシステムがアプリケーションを強制終了する) と、データベースへの接続が切断され、クリーンアップされます。したがって、「永久にロックされる」ということはありません。

02-08 10:40:24.195: E/SqliteDatabaseCpp(7212): sqlite3_exec - Failed to set synchronous mode = 1(Normal) 
02-08 10:40:24.205: E/SQLiteDatabase(7212): Failed to open the database. closing it.

この問題は通常、スレッドがデータベースにアクセスしようとしているが、別のスレッドがロックを持っているか、それを使用していることに起因します。解決策: アプリケーションでデータベースへの接続のインスタンスを 1 つだけ使用します。1 つのアプローチは、インスタンスをサブベッド化された Application クラスに格納することです。

于 2013-02-08T03:04:18.067 に答える