我在发布API 11的手机上运行我的应用程序
然而,当我在模拟器(版本2.2或API 8)上运行时,我的sql lite调用得到以下expcetion
Finalizing a Cursor that has not been deactivated or closed or database not closed error
知道为什么或如何解决这个问题?
由于
答案 0 :(得分:0)
完成光标后,您需要拨打Cursor.close()
。保持不关闭会导致内存泄漏。 E.g:
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();
}
}