2

我正在使用 SQLite 开发一个应用程序。当我从数据库中获取值时,出现以下错误:

10-30 15:06:07.584: ERROR/Database(817): Leak found
10-30 15:06:07.584: ERROR/Database(817): java.lang.IllegalStateException: /data/data/com.fitzsoftware.grocessaryList/databases/example.db SQLiteDatabase created and never closed
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1581)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:659)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:652)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:482)
10-30 15:06:07.584: ERROR/Database(817):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
10-30 15:06:07.584: ERROR/Database(817):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
10-30 15:06:07.584: ERROR/Database(817):     at com.fitzsoftware.grocessaryList.DataHelper.<init>(DataHelper.java:46)
10-30 15:06:07.584: ERROR/Database(817):     at com.fitzsoftware.grocessaryList.MyShoppingList.onCreate(MyShoppingList.java:63)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
10-30 15:06:07.584: ERROR/Database(817):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-30 15:06:07.584: ERROR/Database(817):     at android.os.Looper.loop(Looper.java:123)
10-30 15:06:07.584: ERROR/Database(817):     at android.app.ActivityThread.main(ActivityThread.java:4203)
10-30 15:06:07.584: ERROR/Database(817):     at java.lang.reflect.Method.invokeNative(Native Method)
10-30 15:06:07.584: ERROR/Database(817):     at java.lang.reflect.Method.invoke(Method.java:521)
10-30 15:06:07.584: ERROR/Database(817):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-30 15:06:07.584: ERROR/Database(817):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
10-30 15:06:07.584: ERROR/Database(817):     at dalvik.system.NativeStart.main(Native Method)

从数据库中获取的数据需要很长时间才能显示出来,我认为这是因为这个错误。关于如何解决它的任何建议?

4

1 回答 1

1

看起来您打开了数据库但从不关闭它...?或者可能是损坏的数据库文件......?尝试卸载您的程序并再次运行它。第一次运行时是否遇到相同的错误?- 还是第二次?

于 2010-10-30T09:37:40.963 回答