gpt4 book ai didi

android - 如何避免 DatabaseObjectNotClosedException

转载 作者:太空狗 更新时间:2023-10-29 15:49:21 24 4
gpt4 key购买 nike

我们如何避免这种异常??

01-19 17:16:16.024: WARN/SQLiteCompiledSql(477): Releasing statement in a finalizer.    Please ensure that you explicitly call close() on your cursor: SELECT * FROM test01-19 17:16:16.024: WARN/SQLiteCompiledSql(477): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here01-19 17:16:16.024: WARN/SQLiteCompiledSql(477): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here01-19 17:16:16.024: WARN/SQLiteCompiledSql(477):     at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:62)01-19 17:16:16.024: WARN/SQLiteCompiledSql(477):     at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:80)01-19 17:16:16.024: WARN/SQLiteCompiledSql(477):     at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:46)

最佳答案

我认为出现此错误是因为您没有关闭数据库。始终关闭您的 sqlitehelper 类

已编辑:

你必须在扩展 SQLiteOpenHelper 类的类中这样实现:

@Override
public synchronized void close() {
if(db != null){
db.close();
super.close();
}
}

关于android - 如何避免 DatabaseObjectNotClosedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4734886/

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