As indicated in a previous post People.NUMBER is NOT part of the
People content provider. If you notice, this column is part of
People.PhoneColumns, which means it belongs to Phones, NOT people. I
realize this is a bit confusing. Here is the code you want:

      // create the new person
      ContentValues personInfo = new ContentValues();
      personInfo.put(Contacts.PeopleColumns.NAME, "foo");
      Uri newEntry = getContentResolver().insert(People.CONTENT_URI,
personInfo);

      // build the Uri to the newly inserted person
      Builder b = People.CONTENT_URI.buildUpon();
      b.appendEncodedPath(newEntry.getLastPathSegment());
      Uri newContactUri = b.build();

      // set the values for the phones entry for the contact
      ContentValues phoneNum = new ContentValues();
      phoneNum.put(Contacts.PhonesColumns.NUMBER, "8933892");
      phoneNum.put(Contacts.Phones.PERSON_ID,
newEntry.getLastPathSegment());

      // insert the new phone number into Phones
      getContentResolver().insert(Contacts.Phones.CONTENT_URI,
phoneNum);

Cheers,
Justin
Android Team @ Google

On May 6, 4:11 am, scimitar <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm always getting null as the return uri for
> getContentResolver().insert(). Why is this?
>
>         ContentValues mv = new ContentValues();
>         mv.put(People.NAME, "foo");
>         mv.put(People.NUMBER, "54547");
>         Uri u = getContentResolver().insert(People.CONTENT_URI, mv);
>
> thanks,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to