android开发时使用游标时一定要关闭

时间:2023-03-09 16:51:12
android开发时使用游标时一定要关闭

原代码如下:

places = getPlaceDatas(context, cursor);
cursor.close();

应改为:

try{

places = getPlaceDatas(context, cursor);

}finally{
cursor.close();

}

不然会报如下错误:

java.lang.IllegalStateException: Process 3188 exceeded cursor quota 100, will kill it

相关文章