Android ContentObserver

I have a Cursor 'c' that generates a ListView. The content provider ensures that the ListView will be updated when the underlying data changes. However, I want to additionally make another function call to update my header / footer views every time the list is displayed.

How to implement this with ContentObservers?

+5
source share
1 answer
public void listenChanges() {
 context.getContentResolver().registerContentObserver(CONTENT_URI, true,
 new MyContentObserver());
}

public class MyContentObserver extends android.database.ContentObserver {

 public MyContentObserver() {
  super(null);
 }

 @Override
 public void onChange(boolean selfChange) {
  super.onChange(selfChange);
  //Do all you need here
 }
}
+4
source

All Articles