Wednesday, February 1, 2017

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

During my android development, I came across this during run time:

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

I looked over the internet to look for solution on this issue. Many suggestions came out but only one suggestion solved “android.database.StaleDataException: Attempted to access a cursor after it has been closed” error.

It is by using startManagingCursor(cursor). The “cursor” is your result holder of your db query.

Recommend you that do not use startManagingCursor(cursor).  This method was deprecated in API level 11. 

Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility package.

No comments :

Post a Comment