怎样才能避免DatabaseObjectNotClosedExceptionDatabaseObjectNotClosedException

由网友(窃听)分享简介:我们怎么一避免此异常?01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):在终结释放语句。请确保您显式调用close()在你的光标:SELECT * FROM测试01-19 17:16:16.024:WARN / SQLiteCompiledSql(477):android...

我们怎么一避免此异常?

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();
    }   
}

阅读全文

相关推荐

最新文章