Writing Data managed by a LoaderManager

∥☆過路亽.° 提交于 2019-12-13 00:46:36

问题


When using a LoaderManager, do I still manage my database writes the way I have in the past and let the Loader pick up the changes? I am in the process of converting and adding functionality to an app and I am still getting used to the Android platform.


回答1:


If you are using CursorLoader, and you do all your database updates via the ContentProvider you used with CursorLoader, the loader and its Cursor will be notified of changes, so everything will be handled for you.

If you are not using CursorLoader, it is your responsibility to somehow update your own Cursor. For example, my LoaderEx project has a SQLiteCursorLoader that works directly with a SQLiteOpenHelper, and it offers insert(), update(), delete(), and execSql() methods on the Loader, so we can update the Cursor accordingly.



来源:https://stackoverflow.com/questions/9606598/writing-data-managed-by-a-loadermanager

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