I have registered a CursorLoader
, but it is not receiving updates from my ContentProvider
The sequence of events is:
In a
Fragment
, register the CursorLoader with:getLoaderManager().initLoader(LOADER_FAVS_ID, null, this);
Note I am using the support library version ,so this method is
android.support.v4.app.Fragment.getLoaderManager()
The
CursorLoader
is registered, and aCursor
is loaded in theonLoadFinished
:@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { Log.i(TAG, "onLoadFinished"); switch (loader.getId()) { case LOADER_FAVS_ID: Log.i(TAG, "cursor notification uri: " + cursor.getNotificationUri()); mCursorAdapter.swapCursor(cursor); break; } }
Which Logs
cursor notification uri: content://com.myapp.mylocation/db_locations
, for example. This is because I made sure to callcursor.setNotificationUri(getContext().getContentResolver(), uri);
before returning the Cursor from my ContentProvider. Also note that my content provider returns aMergeCursor
.Some time later, a call is made to
update()
in myContentProvider
, and the following lines are executed:Log.i(TAG, "Notifying uri: " + uri.toString()); getContext().getContentResolver().notifyChange( uri, null);
Which Logs
Notifying loc uri: content://com.myapp.mylocation/db_locations
, the same uri as above.
But onLoadFinished
is never called, and my Cursor
is never updated. I believe I have followed the advice I can find, all of which is basically this. Why else would onLoadFinished
not be called after all of this?