views:

312

answers:

1

I have this scenario

onResume of an activity:

@Override
    protected void onResume() {
        if (adapter1!=null) adapter1.notifyDataSetChanged();
        if (adapter2!=null) adapter2.notifyDataSetChanged();
        if (adapter3!=null) adapter3.notifyDataSetChanged();
        super.onResume();
    }

Adapter has been defined as:

public class ListCursorAdapter extends SimpleCursorAdapter {

   Cursor c;
    /* (non-Javadoc)
     * @see android.widget.CursorAdapter#onContentChanged()
     */
    @Override
    protected void onContentChanged() {
        // this is not called
        if (c!=null) c.requery();
        super.onContentChanged();
    }
}

And the onContentChanged event is not fired, although the onResume and the call to the adapter is issued. What is wrong?

+1  A: 

The onContentChanged method will be called when the ContentObserver on the cursor receives a change notification.

Karan
So in this case, what've I missed? How do I issue the requery?
Pentium10
AFAIK, there isn't any function which will directly requery the cursor. You can write a function in your adapter as requery which will requery the cursor and call notifyDataSetChanged from there.
Karan