views:

81

answers:

0

Im trying to insert a new contact into androids contact list. Adding a name and phone numbers works fine, but adding an email address doesnt work. My code:

//name is a string
//phone and email are string arrays
ContentValues values = new ContentValues();
values.put(People.NAME, name);
Uri newPerson = People.createPersonInMyContactsGroup(cr, values);
if (newPerson != null) {
    for (i=0; i<phone.length; i++) {
        Log.i("Phone",""+phone[i]);
        values.clear();
        Uri mobilesUri = Uri.withAppendedPath(newPerson,People.Phones.CONTENT_DIRECTORY);
        values.put(People.Phones.NUMBER,phone[i]);
        values.put(People.Phones.TYPE,People.Phones.TYPE_MOBILE);
        Uri phonesUpdate = cr.insert(mobilesUri, values);
    }
    for (i=0; i<email.length; i++) {
        Log.i("Email",""+email[i]);
        values.clear();
        Uri emailUri = Uri.withAppendedPath(newPerson,People.ContactMethods.CONTENT_DIRECTORY);
        values.put(People.ContactMethods.KIND,People.ContactMethods.KIND_EMAIL);
        values.put(People.ContactMethods.TYPE,People.ContactMethods.TYPE_HOME);
        values.put(People.ContactMethods.DATA,email[i]);
        Uri emailUpdate = cr.insert(emailUri, values);
    }
}

Im getting an error in line:

values.put(People.ContactMethods.KIND,People.ContactMethods.KIND_EMAIL);

of

error: cannot find symbol

edit:

forgot to mention im using xcode/ant and revision 8 (froyo 2.2)