Delete contact via adb


How can I delete a contact using the adb shell? I know the raw_contact_id of the contact.

I tried different ways but none with success.

  1.   To edit a contact I used the command

    am start -a android.intent.action.EDIT content://contacts/people/8

    and it worked.

    But deleting it with

    am start -a android.intent.action.DELETE content://contacts/people/8

    does not work and showed me this error message:

    Activity not started, unable to resolve Intent { act=android.intent.action.DELETE dat=content://contacts/people/8 flg=0x10000000 }

    (flg=0x10000000 means FLAG_RECEIVER_FOREGROUND, I think it is set automatically.)

    Do I have to set some flags? Or why does this not work?

  2. A more fancy way is to simulate the process, how a normal user deletes the contact.

    am start -a android.intent.action.VIEW content://contacts/people/8
    input keyevent 22  # right button
    input keyevent 22  # reach field in the right corner
    input keyevent 66  # enter
    input keyevent 20  # go down
    input keyevent 20  # go down --> reached "Delete"
    input keyevent 66  # enter
    input keyevent 22  # button "Ok"
    input keyevent 66  # enter

    After clicking on the "Delete" button, the contact app always crashes (Contacts has been closed). Using these key events never worked on my emulator -- if I click on the buttons by hand (with my mouse), everything works…

  3. Third way could be deleting the entries in the databases. This does not make sense for me, because then they are completely deleted -- if they are deleted the "normal" way, the contacts are still stored in some tables (like "deleted contacts").

asked on Stack Overflow May 12, 2014 by CFP • edited Aug 29, 2015 by Brian Tompsett - 汤莱恩

1 Answer


The content://contacts provider has been deprecated. You should be using content:// instead:

$ adb shell content query --uri content://

To remove contact (where's id = 1)

$ adb shell content delete --uri content://

To remove all contacts at once

$ adb shell pm clear
answered on Stack Overflow Nov 10, 2020 by The Mauler • edited Nov 13, 2020 by The Mauler

User contributions licensed under CC BY-SA 3.0