FaisalAhmed FaisalAhmed - 3 months ago 39
Android Question

Diference between cursor.setNotificationUri() and getContentResolver().notifyChange(uri,null)

I am new to android can any one tell me what is the difference between

while implementing content provider.

I have seen that
is used in query method and while updating or inserting new getContentResolver() is used.

I have little understanding that
notify resolver that some that has been changed but what does
does there ?


They are used symbiotically. If you are implementing a ContentProvider, essentially when someone queries your provider, you produce a Cursor and call setNotificationUri() on it with some rational Uri (such as the Uri used to make the query). Later, if data served by your ContentProvider changes, e.g. after an insert/update/delete, you call getContentResolver().notifyChange(uri, null) so that anyone who currently has a Cursor (because they queried earlier) gets notified that data has changed and they should re-query. If they are using a CursorLoader, the re-query happens automatically.