Question

I've currently written an app that is observing the content://sms URI for any changes to the database. My observer is successfully being triggered when individual messages are added or removed, however, no notification is triggered when an entire thread is deleted at once. Is there any way to get this event to trigger? Or maybe there's another content provider I should be observing?

Uri URI = Uri.parse("content://sms");
String[] columns = {"_id", "date"};
Cursor c = getContentResolver().query(URI, columns, "type=?", new String[]{"1"}, "_id DESC");

Observer observer = new Observer();
c.registerContentObserver(observer);

And my observer class:

private class Observer extends ContentObserver {

    public Observer() {
        super(null);
    }

    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);

        if (!selfChange) {
            // do stuff
            // never called when a thread is deleted
        }
    }
}
Was it helpful?

Solution

I switched to observing the content://mms-sms/conversations content provider. This provider properly signals my observer when a thread is deleted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top