StrictMode is throwing DatabaseObjectNotClosedException when using CursorLoader and leaving the current activity
-
07-02-2021 - |
Question
I'm using a very basic example where I create a CursorLoader
with a uri from my content provider and populate a map. Everything works smoothly but when I leave that activity I get a DatabaseObjectNotClosedException
thrown by StrictMode. I understand that the CursorLoader
deals with the Cursor so I must not close it myself. So why does this happen?
This problem doesn't appear when using a ListFragment and I guess it's because in onLoaderReset()
I do adapter.swapCursor(null)
. But what should I do in my map fragment (or any other kind of fragment where I don't have a list) in the onLoaderReset()
method? At the moment, I'm not doing anything because I don't hold a reference to the cursor returned.
Solution
The revision 4 of ACL fixed these issues.