---
title: "how to know if a contact is added, changed or deleted in android"  
description: "how to know if a contact is added, changed or deleted in android"  
author: "Allen Scott"  
published: 2015-11-16  
updated: 2023-07-02  
canonical: https://www.mindstick.com/forum/33598/how-to-know-if-a-contact-is-added-changed-or-deleted-in-android  
category: "android"  
tags: ["android", "android controls", "android libraries"]  
reading_time: 4 minutes  

---

# how to know if a contact is added, changed or deleted in android

I am working on an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) whereby I need to [listen](https://yourviews.mindstick.com/audio/1235/mastering-in-link-building-how-listen-here) to changes in [native](https://answers.mindstick.com/qa/43346/what-did-almost-all-native-american-societies-have-in-common-in-the-1400s) [contacts](https://answers.mindstick.com/qa/50746/how-to-setup-your-contacts-on-your-iphone-7) [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) like if a contact is edited/[deleted](https://www.mindstick.com/forum/160487/how-to-remove-the-deleted-git-code-marker-in-scrollbar-in-visual-studio-2022) or a new contact is added.

I know I can achieve this with the help of contentobservers. However I found it pretty strange that android [SDK](https://www.mindstick.com/blog/260/creating-window-program-in-vc-by-using-sdk) does not provide a way to know which contact is added/deleted or which one is changed. This [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) in a lot of [manual](https://www.mindstick.com/blog/11996/complete-manual-guide-for-linksys-extender-setup) work like traversing through entire contact list and checking which one is changed.

I want to know if there is any better way of achieving this. I know this [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) would have been asked many times but I want to know why Android SDK does not have such a mechanism in place?

## Replies

### Reply by Aryan Kumar

There are a few ways to know if a contact is added, changed, or deleted in Android.

- **Use the Contacts Provider**. The Contacts Provider is a data store that contains all of the contacts on the device. You can query the Contacts Provider to see if a contact has been added, changed, or deleted.
- **Use the ContentResolver**. The ContentResolver is a class that provides access to the data on the device, including the Contacts Provider. You can use the ContentResolver to query the Contacts Provider to see if a contact has been added, changed, or deleted.
- **Use the Contacts app**. The Contacts app provides a notification when a contact is added, changed, or deleted. You can also manually check the Contacts app to see if a contact has been added, changed, or deleted.

Here are the steps on how to use the Contacts Provider to see if a contact has been added, changed, or deleted:

1. Go to **Settings** > **Apps** > **Contacts**.
2. Tap on **Permissions**.
3. Toggle the switch next to **Contacts** to **On**.
4. Open a **Terminal** or **Command Prompt** window.
5. Type the following command and press **Enter**:

Code snippet

```plaintext
adb shell content query --uri content://com.android.contacts/contacts
```

This command will list all of the contacts on the device.

1. To see if a contact has been added, changed, or deleted, compare the list of contacts to the list of contacts that you had before.

Here are the steps on how to use the ContentResolver to see if a contact has been added, changed, or deleted:

1. Go to **Settings** > **Apps** > **Contacts**.
2. Tap on **Permissions**.
3. Toggle the switch next to **Contacts** to **On**.
4. Open a **Terminal** or **Command Prompt** window.
5. Type the following command and press **Enter**:

Code snippet

```plaintext
adb shell content query --uri content://com.android.contacts/contacts/lookup/<CONTACT_ID>
```

Replace `<CONTACT_ID>` with the ID of the contact that you want to check.

1. If the command returns a row, the contact exists. If the command does not return a row, the contact does not exist.

Here are the steps on how to use the Contacts app to see if a contact has been added, changed, or deleted:

1. Open the Contacts app.
2. Look for the contact that you want to check.
3. If the contact is not there, it has been deleted. If the contact is there, it has been added or changed.

You can also manually check the Contacts app to see if a contact has been added, changed, or deleted by looking at the date and time that the contact was last modified.

### Reply by Anonymous User

[This interesting thread from the early days of Android](https://groups.google.com/d/msg/android-developers/oayhLnhmQGQ/OYqkBEIm644J) indicates that the ContentObserver did use to tell you what had changed, but it was too difficult to provide that information. It goes on to state why (at least at that time) re-querying was thought to be good enough and safer.


---

Original Source: https://www.mindstick.com/forum/33598/how-to-know-if-a-contact-is-added-changed-or-deleted-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
