怎样才能避免DatabaseObjectNotClosedException [英] How can one avoid DatabaseObjectNotClosedException
本文介绍了怎样才能避免DatabaseObjectNotClosedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们怎么一避免此异常?
01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):在终结释放语句。请确保您显式调用close()在你的光标:SELECT * FROM测试 01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):android.database.sqlite.DatabaseObjectNotClosedException:应用程序没有关闭在这里打开的游标或数据库对象 01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):android.database.sqlite.DatabaseObjectNotClosedException:应用程序没有关闭在这里打开的游标或数据库对象 01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):在android.database.sqlite.SQLiteCompiledSql(SQLiteCompiledSql.java:62) 01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):在android.database.sqlite.SQLiteProgram(SQLiteProgram.java:80) 01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):在android.database.sqlite.SQLiteQuery(SQLiteQuery.java:46)
解决方案
我觉得出现这个错误,因为你没有关闭数据库。始终关闭您的sqlitehelper类
编辑:
您必须实现这样在你的类,它正在扩展SQLiteOpenHelper类:
@覆盖
市民同步无效的close(){
如果(DB!= NULL){
db.close();
super.close();
}
}
How one we avoid this exception??
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 test 01-19 17:16:16.024: WARN/SQLiteCompiledSql(477): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here 01-19 17:16:16.024: WARN/SQLiteCompiledSql(477): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here 01-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)
解决方案
I think this error appears because you didn’t close your database. Always close your sqlitehelper class
EDITED:
You have to implement like this in your class which is extending SQLiteOpenHelper class:
@Override
public synchronized void close() {
if(db != null){
db.close();
super.close();
}
}
这篇关于怎样才能避免DatabaseObjectNotClosedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文