2011-04-18 59 views
0

我創建了有關於一些地方..then我從數據庫中檢索到顯示谷歌地圖上的位置信息數據的基礎上..安卓:問題在數據庫

當我調試應用程序時出現此異常「 SQLiteCursor.finalize()」中IllegalStateException異常類..

,這是一個logcat的輸出:

04-18 14:58:51.815: ERROR/ActivityThread(263): Failed to find provider info for com.google.settings 
04-18 14:58:51.825: ERROR/ActivityThread(263): Failed to find provider info for  com.google.settings 
04-18 14:58:51.975: ERROR/ActivityThread(263): Failed to find provider info for com.google.settings 
04-18 14:58:52.845: DEBUG/dalvikvm(263): GC freed 3178 objects/193168 bytes in 80ms 
04-18 14:58:53.445: ERROR/Database(263): Leak found 
04-18 14:58:53.445: ERROR/Database(263): java.lang.IllegalStateException: /data/data/ksu.project.gotour/databases/GoTour.db SQLiteDatabase created and never closed 
04-18 14:58:53.445: ERROR/Database(263):  at android.database.sqlite.SQLiteDatabase. <init>(SQLiteDatabase.java:1694) 
04-18 14:58:53.445: ERROR/Database(263):  at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738) 
04-18 14:58:53.445: ERROR/Database(263):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:760) 
04-18 14:58:53.445: ERROR/Database(263):  at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:753) 
04-18 14:58:53.445: ERROR/Database(263):  at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:473) 
04-18 14:58:53.445: ERROR/Database(263):  at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193) 
04-18 14:58:53.445: ERROR/Database(263):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) 
04-18 14:58:53.445: ERROR/Database(263):  at ksu.project.gotour.EventData.Visited(EventData.java:236) 
04-18 14:58:53.445: ERROR/Database(263):  at ksu.project.gotour.spotInfo$2.onCheckedChanged(spotInfo.java:73) 
04-18 14:58:53.445: ERROR/Database(263):  at android.widget.CompoundButton.setChecked(CompoundButton.java:122) 
04-18 14:58:53.445: ERROR/Database(263):  at android.widget.CompoundButton.toggle(CompoundButton.java:85) 
04-18 14:58:53.445: ERROR/Database(263):  at android.widget.CompoundButton.performClick(CompoundButton.java:97) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.View.onTouchEvent(View.java:4179) 
04-18 14:58:53.445: ERROR/Database(263):  at android.widget.TextView.onTouchEvent(TextView.java:6540) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.View.dispatchTouchEvent(View.java:3709) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
04-18 14:58:53.445: ERROR/Database(263):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 
04-18 14:58:53.445: ERROR/Database(263):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 
04-18 14:58:53.445: ERROR/Database(263):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 
04-18 14:58:53.445: ERROR/Database(263):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 
04-18 14:58:53.445: ERROR/Database(263):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 
04-18 14:58:53.445: ERROR/Database(263):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-18 14:58:53.445: ERROR/Database(263):  at android.os.Looper.loop(Looper.java:123) 
04-18 14:58:53.445: ERROR/Database(263):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
04-18 14:58:53.445: ERROR/Database(263):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-18 14:58:53.445: ERROR/Database(263):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-18 14:58:53.445: ERROR/Database(263):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
04-18 14:58:53.445: ERROR/Database(263):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
04-18 14:58:53.445: ERROR/Database(263):  at dalvik.system.NativeStart.main(Native Method) 
04-18 14:58:53.805: DEBUG/dalvikvm(263): GC freed 844 objects/73448 bytes in 135ms 
04-18 14:58:54.176: ERROR/Exception on query(263): java.lang.NumberFormatException: 
04-18 14:58:57.075: DEBUG/dalvikvm(263): threadid=5: still suspended after undo (sc=1 dc=1 s=Y) 
04-18 14:58:57.075: DEBUG/dalvikvm(263): GC freed 5454 objects/334000 bytes in 92ms 
04-18 14:59:00.556: INFO/MapActivity(263): Handling network change notification:CONNECTED 
04-18 14:59:03.896: INFO/dalvikvm(263): Debugger is attached -- suppressing HeapWorker watchdog 

而這是用於logcat的圖片。也許它更清楚。

http://download.mrkzy.com/e/1811_md_13031326851.png http://download.mrkzy.com/e/1811_md_13031326852.png

非常感謝

+0

消息非常明確:在停止使用數據庫之前,您並未關閉數據庫。解決該問題。 – Mat 2011-04-18 13:30:04

+0

基於日誌在這裏我想你沒有關閉你在你的類中創建的數據庫對象。你有使用dbObj.close(); – 2011-04-18 13:31:09

+0

請問你可以從ksu.project.gotour.EventData.Visited(EventData.java:236)發佈你的代碼嗎?無論何時使用數據庫幫助程序,您都應該進行檢查:您無需在每次查詢之前打開數據庫。您只需在Activity生命週期中執行一次。另外,不要忘記在onPause回調中關閉數據庫。 – 2011-04-24 11:03:17

回答

0

異常"SQLiteCursor.finalize()" in IllegalStateException Class可以,如果你不再需要的時候都不會關閉遊標出現。所以,不要忘記爲光標執行close()。 這不是關鍵的異常,所以應用程序可以忍受這一點,但在此異常調試eclipse中斷時。

+0

我正在關閉遊標和數據庫中的每個活動.. 不存在一些活動不工作,因爲這種異常:( – khawlah 2011-04-18 21:10:13