Question

To add a contact via adb shell I use the command

am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact

and for extra information

-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
Add string data as a key-value pair. 

so e.g. a contact 'Donald Duck' with number 123-456 is created by

am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name 'Donald Duck' -e phone 123-456

The telephonebook has 12 mimetypes:

_id: mimetype
1: vnd.android.cursor.item/email_v2
2: vnd.android.cursor.item/im
3: vnd.android.cursor.item/nickname
4: vnd.android.cursor.item/organization
5: vnd.android.cursor.item/phone_v2
6: vnd.android.cursor.item/sip_address
7: vnd.android.cursor.item/name
8: vnd.android.cursor.item/postal-address_v2
9: vnd.android.cursor.item/identity
10: vnd.android.cursor.item/photo
11: vnd.android.cursor.item/group_membership
12: vnd.android.cursor.item/website

For an email address it is "email", for name it's "name", for "phone_v2" it's phone. But I did not find any key which works for e.g. "postal-address", "organization" or "website".

How can I find out, which EXTRA_KEY is necessary to add these extra information?

Was it helpful?

Solution

Found it. In the !incredible clear and well arranged android dev docs! 😒 from http://developer.android.com/reference/android/provider/ContactsContract.Intents.Insert.html#POSTAL :

public static final String POSTAL

The extra field for the contact postal address.

Type: String

Constant Value: "postal"

Interactive example (if you have the dialog command available), in my local debian chroot @ /usr/local/bin/android.add:

#!/bin/sh
/system/bin/am start -a android.intent.action.INSERT -t vnd.android.cursor.dir/contact -e name "$(dialog --stdout --inputbox 'Contact Name' 0 0)" -e postal "$(dialog --stdout --inputbox 'Postal Address' 0 0)" -e phone "$(dialog --stdout --inputbox 'Phone Number' 0 0)" -e email "$(dialog --stdout --inputbox 'Email' 0 0)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top