gpt4 book ai didi

android - 什么是 "SQLiteDatabase created and never closed"错误?

转载 作者:太空宇宙 更新时间:2023-11-03 13:03:50 25 4
gpt4 key购买 nike

我已经在我的适配器类中关闭了数据库,所以为什么这个错误会出现在 logcat 上,但我的应用程序不会强制关闭,但日志 cat 上只会显示错误。我应该关闭数据库以忽略此错误...?

我的错误是……下面……我在哪个类(class)离开了数据库……我从这个链接中得到了帮助http://www.vogella.de/articles/AndroidSQLite/article.html

ERROR/Database(265): Leak found
ERROR/Database(265): java.lang.IllegalStateException: /data/data/expenceanywhere.mobile/databases/data SQLiteDatabase created and never closed
ERROR/Database(265): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1581)
ERROR/Database(265): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
ERROR/Database(265): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:659)
ERROR/Database(265): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:652)
ERROR/Database(265): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:482)
ERROR/Database(265): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
ERROR/Database(265): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
ERROR/Database(265): at expenceanywhere.mobile.NotesDbAdapter.open(NotesDbAdapter.java:56)
ERROR/Database(265): at expenceanywhere.mobile.AddEditExpense.onCreate(AddEditExpense.java:199)
ERROR/Database(265): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
ERROR/Database(265): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
ERROR/Database(265): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
ERROR/Database(265): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
ERROR/Database(265): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
ERROR/Database(265): at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/Database(265): at android.os.Looper.loop(Looper.java:123)
ERROR/Database(265): at android.app.ActivityThread.main(ActivityThread.java:4203)
ERROR/Database(265): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/Database(265): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/Database(265): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
ERROR/Database(265): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
ERROR/Database(265): at dalvik.system.NativeStart.main(Native Method)

最佳答案

记得总是在 Helper 类中关闭 db

//---closes the database---    
public void close()
{
DBHelper.close();
}

类似问题:Sqlite Database LEAK FOUND exception in android?

关于android - 什么是 "SQLiteDatabase created and never closed"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7632047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com