Hello scimitar,

People.NUMBER is in android.provider.Contacts.PhonesColumns, not in
String android.provider.Contacts.PeopleColumns. Therefore you need to
insert the people table first with the name and get its _id from the
insert method's returned URI.

Uri myUri = getContentResolver().insert(People.CONTENT_URI, mv);
String newlyInsertedId  = myUri.getLastPathSegment();

By the help of the newlyInsertedId, insert a phone tuple with the
number into the phones table by the help of content provider.

Best wishes,
-sacoskun

On May 6, 1:24 pm, scimitar <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm trying to add a contact to the phone contact list, but apparaently
> ContentResolver().insert() is not adding it. (The cursor's count()
> method gives the same result).  My code is sth like this:
>
> Cursor c = getContentResolver().query(
>                         People.CONTENT_URI, null, null, null, null);
>         startManagingCursor(c);
>
>         columns = new String[] {People.NAME};
>         names = new int[] {R.id.row_entry};
>
>         mAdapter =
>                 new SimpleCursorAdapter(this, R.layout.main,
>                                 c, columns, names);
>         setListAdapter(mAdapter);
>
>         int count = c.count();
>         ContentValues mv = new ContentValues();
>         mv.put(People.NAME, "foo");
>         mv.put(People.NUMBER, "54547");
>         getContentResolver().insert(People.CONTENT_URI, mv);
>         getContentResolver().notifyChange(People.CONTENT_URI, null);
>         c.requery();
>         int ccount = c.count();
>
> 'count' and 'ccount' are giving me the same values. Why is this?
>
> thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
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