How do I make my Android ContentObserver for ContactsContract detect a added, updated or deleted contact?

前端 未结 4 660
無奈伤痛
無奈伤痛 2020-12-05 02:18

I am able to get a generic notification \"that there was a change to the contacts DB\", but I want to know the specific record that was inserted, updated, or deleted. Follo

4条回答
  •  清歌不尽
    2020-12-05 02:57

    First of all, you have to register your contentObserver to receive change notification.

    Do this by calling :

    registerContentObserver();
    

    Here's the specs : registerContetObserver

    After than you'll want to notify all the listeners when a modification happens :

    contentResolver.notifyChange();
    

    Here's the specs for that one : notifyChange

    Hope it helps ;)

    Cheers !

提交回复
热议问题