Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
contact info query and update in new sdk
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
CJ  
View profile  
 More options Feb 22 2008, 10:52 am
From: CJ <Chunyu.Ji...@gmail.com>
Date: Fri, 22 Feb 2008 07:52:32 -0800 (PST)
Local: Fri, Feb 22 2008 10:52 am
Subject: contact info query and update in new sdk
Apparently, the following code stopped working in the new SDK. Can
anybody give an update?
To be more specific, the last line of the code
        ContentURI emailUpdate =
getContentResolver().insert(newPerson.addPath(Contacts.ContactMethods.CONTE ­
NT_URI.getPath()),
email);

Because addPath() is no longer available, can any expert give an
update?
Thanks a ton

Here's some code to demonstrate this:// create the values for your test person
ContentValues person = new ContentValues();
person.put(Contacts.People.NAME, "Test Name");
person.put(Contacts.People.COMPANY, "Test Company");
person.put(Contacts.People.NOTES, "Test Notes");

// insert the information in the contacts
ContentURI newPerson =
getContentResolver().insert(Contacts.People.CONTENT_URI, person);

// check to make sure the update was successful.  If so, your
ContentURI returned
// will look something like this
// content://contacts/people/1
//
if (newPerson != null) {

        // create values to add a phone number
        ContentValues number = new ContentValues();
        number.put(Contacts.Phones.PERSON_ID,
newPerson.getPathLeaf());
        number.put(Contacts.Phones.NUMBER, "(888) 555-1212");

        // insert it into the contacts
        ContentURI phoneUpdate =
getContentResolver().insert(Contacts.Phones.CONTENT_URI, number);

        // create values for the email address
        ContentValues email = new ContentValues();
        email.put(Contacts.ContactMethods.PERSON_ID,
newPerson.getPathLeaf());
        email.put(Contacts.ContactMethods.KIND,
Contacts.ContactMethods.EMAIL_KIND);
        email.put(Contacts.ContactMethods.TYPE,
Contacts.ContactMethods.EMAIL_KIND_HOME_TYPE);
        email.put(Contacts.ContactMethods.DATA, "t...@test.com");

        // the key here is that when you insert the email into the
Contacts,
be sure to use the path for the person
        // that was returned originally, and then add the path to the
ContactMethods at the end of this URL
        ContentURI emailUpdate =
getContentResolver().insert(newPerson.addPath(Contacts.ContactMethods.CONTE ­
NT_URI.getPath()),
email);


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Twyst  
View profile  
 More options Feb 22 2008, 11:15 am
From: Twyst <gosl...@gmail.com>
Date: Fri, 22 Feb 2008 08:15:51 -0800 (PST)
Local: Fri, Feb 22 2008 11:15 am
Subject: Re: contact info query and update in new sdk
I replaced ContentURIs with Uri (capital U).

To imitate ContentURI.addPath() I do:

Builder myBuilder = uri.buildUpon().appendEncodedPath();

or

Builder myBuilder = uri.buildUpon().appendPath();

Then:

myBuilder.build() generates the new Uri for you.

I don't know if that's ideal.  But it works.

On Feb 22, 9:52 am, CJ <Chunyu.Ji...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
j  
View profile  
 More options Feb 29 2008, 11:40 pm
From: j <jac...@gmail.com>
Date: Fri, 29 Feb 2008 20:40:40 -0800 (PST)
Local: Fri, Feb 29 2008 11:40 pm
Subject: Re: contact info query and update in new sdk
This works in m5 SDK:

                ContentValues person = new ContentValues();
                person.put(Contacts.People.NAME, "Test User");
                person.put(Contacts.People.COMPANY, "Test Company");
                person.put(Contacts.People.NOTES, "eNotes");

                Uri newPerson =
                        context.getContentResolver().insert(Contacts.People.CONTENT_URI,
person);

                if (newPerson != null) {
                        // add a mobile phone number
                        ContentValues number = new ContentValues();
                        List<String> pathList = newPerson.getPathSegments();
                        String pathLeaf =  pathList.get(pathList.size() -1 );
                        number.put(Contacts.Phones.PERSON_ID,pathLeaf);
                        number.put(Contacts.Phones.NUMBER, "(408) 111-1111");

                        // insert it into the contacts
                        Uri phoneUpdate =
                                context.getContentResolver().insert(Contacts.Phones.CONTENT_URI,
number);

}

But the email part doesn't seem to work though.

On Feb 22, 7:52 am, CJ <Chunyu.Ji...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google