StrictMode is throwing DatabaseObjectNotClosedException when using CursorLoader and leaving the current activity

StackOverflow https://stackoverflow.com/questions/7676667

  •  07-02-2021
  •  | 
  •  

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.

有帮助吗?

解决方案

The revision 4 of ACL fixed these issues.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top