android.database.StaleDataException: Attempted to access a cursor after it has b

故障现象描述

1.新建图片便签

2.拍照生成图片,点击图片,便签应用挂掉,但是便签已经生成了。

分析log:android.database.StaleDataExceptionAttempted to access a cursor after it habeen

但是同样的代码在android2.2上边没有发生,在android4.0上边发生了,分析原因在于

android4.0的managedCursor /managedQuery会自动的close一个cursor,但是我们又手动的关闭了一次,所以导致了这个问题,解决方案是在4.0的代码去掉close这个操作。

 

解决这个问题的关键是对于log的分析和对于网络资料的查找,但是从代码中查找问题的发生点时,我的思路明显狭窄,没有找对地方,后来同事经验较丰富,找对了地方,解决起来就很快。

 

 

解决方法:

  1.  if(Integer.parseInt(Build.VERSION.SDK) < 14)  
  2.                 {  
  3.                     cursor.close();  
  4.                 }  

参考资料:

http://code.google.com/p/android/issues/detail?id=23746

猜你喜欢

转载自coolwhy1.iteye.com/blog/1722297