0

In my application I am keeping a copy of all contacts in a HashMap (key = phone-number formatted by Google phone lib, value = name) to look-up a person's contact name by phone number quickly.

I want to update my HashMap when a new contact is added to the phone; how can I capture this event in my application and update my contacts list HashMap?

Any useful article or a piece of code would be really helpful.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ankur Teotia
  • 227
  • 1
  • 10
  • Periodically checking using services can help. – Uma Kanth Jan 12 '16 at 10:11
  • let me try that and get back to you, thanks for the quick reply . – Ankur Teotia Jan 12 '16 at 10:20
  • Did you check this question: http://stackoverflow.com/questions/5733775/broadcast-on-contact-add-change – W.K.S Jan 12 '16 at 10:52
  • Ok, so using content observer, i can catch when a contact is modified, deleted or added, but getting the exact contact uri of the changed contact would be cherry on top, if anyone can help me out with that, that would be just too dam good. Used this to observe for contact changes > this.getContentResolver().registerContentObserver( ContactsContract.Contacts.CONTENT_URI, true, mObserver); – Ankur Teotia Jan 12 '16 at 11:30

0 Answers0