Question

Do I need to be concerned about making sure the database is closed when a FragmentActivity that uses a LoaderEx SQLiteCursorLoader is paused or destroyed?
Thanks much

Was it helpful?

Solution

When the FragmentActivity is destroyed, it should call reset() on all Loader instances it created, which will call onReset() in the Loader implementation, which in SQLiteCursorLoader calls close() on any outstanding Cursor.

Note that this happens when the activity is destroyed. There does not seem to be a Loader equivalent of the managed Cursor concept of deactivating the Cursor when the activity is paused. That's a pity, as that was a nice heap management feature, and I'll ponder how to best support that.

If you find evidence that something is being leaked, file an issue in the LoaderEx project with details of how to reproduce the error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top