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

来源:互联网 发布:js 时间戳格式化函数 编辑:程序博客网 时间:2024/05/22 18:24
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(); // 此处可以根据情况关闭与否}

0 0
原创粉丝点击