使用commonsware loaderex SQLiteCursorLoader时是否以及何时关闭数据库?
当使用 LoaderEx SQLiteCursorLoader 的 FragmentActivity 暂停或销毁时,我是否需要担心确保数据库关闭?
非常感谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当
FragmentActivity
被销毁时,它应该在它创建的所有Loader
实例上调用reset()
,这将调用onReset()< /code> 在
Loader
实现中,在SQLiteCursorLoader
中对任何未完成的Cursor
调用close()
。请注意,当活动被销毁时,就会发生这种情况。似乎没有一个
Loader
相当于在活动暂停时停用Cursor
的托管Cursor
概念。这很遗憾,因为这是一个很好的堆管理功能,我将考虑如何最好地支持它。如果您发现有证据表明某些内容正在泄露,请在 LoaderEx 项目中提交问题并提供详细信息如何重现错误。
When the
FragmentActivity
is destroyed, it should callreset()
on allLoader
instances it created, which will callonReset()
in theLoader
implementation, which inSQLiteCursorLoader
callsclose()
on any outstandingCursor
.Note that this happens when the activity is destroyed. There does not seem to be a
Loader
equivalent of the managedCursor
concept of deactivating theCursor
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.