Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 终结尚未停用或关闭的游标或数据库未关闭错误_Android_Android Sqlite - Fatal编程技术网

Android 终结尚未停用或关闭的游标或数据库未关闭错误

Android 终结尚未停用或关闭的游标或数据库未关闭错误,android,android-sqlite,Android,Android Sqlite,我在我的手机上运行我的应用程序,它发布了API 11 但是,当我在emulator(版本2.2或API 8)上运行时,我会得到以下sql lite调用的表达式 Finalizing a Cursor that has not been deactivated or closed or database not closed error 知道为什么或者如何解决这个问题吗 谢谢使用完光标后,需要调用cursor.close()。不关闭会导致内存泄漏。例如: Cursor cursor = null

我在我的手机上运行我的应用程序,它发布了API 11

但是,当我在emulator(版本2.2或API 8)上运行时,我会得到以下sql lite调用的表达式

Finalizing a Cursor that has not been deactivated or closed or database not closed error
知道为什么或者如何解决这个问题吗


谢谢

使用完光标后,需要调用
cursor.close()
。不关闭会导致内存泄漏。例如:

Cursor cursor = null;
try {
    cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null);
    if (cursor != null && cursor.moveToFirst()) {
        // moar code
    }
} finally {
    if (cursor != null) {
        cursor.close();
    }
}

哦,真的吗?我很惊讶所有的SQLLite示例和教程都没有提到要关闭它。好吧,现在有一个示例提到了它:)