您的位置:首页 > 移动开发 > Objective-C

android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or da

2014-01-08 11:52 477 查看
Cursor cursor=null;
Cursor cursor2=null;
db = helper.getReadableDatabase();
try{

cursor=rawQuery("...",null);
while (cursor.moveToNext())
{

// ...

cursor2=db.rawQuery("select file_path from memos where time > "+date+" and time < "+lg+" order by time desc",null);
if(cursor2.moveToNext()){

//...
}
cursor2.close();  // 因是在循环内,要在此处加上关闭,而不仅只在finally中关闭

// ...

}
}

}finally{

if(cursor!=null){
cursor.close();
}
if(cursor2!=null){
cursor2.close();
}

db.close(); // 此处可以根据情况关闭与否

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐