Search code examples
androidandroid-loadermanager

Writing Data managed by a LoaderManager


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.


Solution

  • 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.