I am using ContentProvider, CursorLoader and ListFragment. In 
onActivityCreated() method of ListFragment, I am calling initLoader()to 
load already inserted record from database into ListFragment. In onResume() 
of ListFragment I have also started a IntentService to insert another 10 
rows. My data is inserted into the database, but the ListFrament is not 
refreshed. onLoadFinished()method is not called for second time, though 
inside ContentProvider in Insert(),update() and delete() method I have 
added 

getContext().getContentResolver().notifyChange(_uri, null);

I think passing null for observer is ok as in “Grep code”, I checked that 
CursorLoader has registerContentObserver () method. The adapter definition 
is as followed.

new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, 
null, new String[]{ "book_title", "book_author" }, new int[]{ 
android.R.id.text1, android.R.id.text2 }, 0);

 

In ContentProvider Query() method I have also added 

c.setNotificationUri(getContext().getContentResolver(), uri);

 

If I call restartLoader() then only the ListFragment  get refreshed.

Please let me know how can I observe database with CursorLoader or any 
other Loader.

Am I missing any step? Or can you refer me any site how to observe content 
with CursorLoader?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to