How to (properly) transition from startManagingCursor to CursorLoader?

ε祈祈猫儿з 提交于 2019-11-30 08:25:40

First, startManagingCursor() still works. It is not ideal, in that it performs database I/O on the main application thread. In Android, "deprecated" generally means "we have something else that we think is better that we suggest you use". So, when it makes sense in the development cycle of your app, you should consider migrating.

Second, as Selvin noted, the SDK only provides a Loader implementation for a ContentProvider. I have a project that offers a Loader for SQLite directly.

Third, there really is no straight-up "translation" for your code. The Loader framework is asynchronous and event-driven, whereas your code is not.

Generally speaking, your Loader would be responsible for fetching the notes, and you would populate your ListView in onLoadFinished(), when you are delivered the Cursor from the Loader.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!