[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-12-17 Thread DulcetTone
oops... did a little looking.
I guess you're going to be "commonsguy".

tone

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-12-17 Thread DulcetTone
Mark, did you finish this and post it somewhere?
How do I look for it?

I am enjoying my "warescription", by the way.  I will look for a
feedback link on your site, as I have some.

tone

On Nov 26, 7:42 am, Mark Murphy  wrote:

> This is a fragment of a sample that I'll be uploading to github tomorrow
> sometime (I hope). NewContactsAdapterBridge uses ContactsContract;
> OldContactsAdapterBridge uses Contacts. So long as you don't try
> *loading* a class that uses 2.0 APIs, you won't get a VerifyError. The
> 2.0-referencing class can still be in the APK, though.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Tim Jowers
I agree with you Axel, I got it working. But shouldn't have had to do so.
The larger moose is version compatibility. The industry standard is
two versions back the API should work. Apache does not honor this.
Now, Google is not either. It is PAINFUL to partner. In my case, 10
hours plus future maintenance headaches.

Well, its a great platform nonetheless. Just in its infancy I guess.

Tim


On Thu, Nov 26, 2009 at 10:44 AM, axel  wrote:
>> You will need to use reflection (or intelligent class loading) and use
>> the ContactsContracts provider when running on Android 2.0, allowing
>> your existing Contacts code to be used on 1.5/1.6.
> The Contacts.ContactMethods API is deprecated but not dropped. And
> even deprecated APIs are required to function properly.
> Google has to make sure (and even stated it in this forum) that this
> is the case. It cannot be the idea for applications to check the
> Android version invoke APIs accordingly via reflection.
> I don't like to receive complaints from user that my application
> doesn't work properly on their phone but if Google doesn't ensure that
> event deprecated APIs, it is not my fault.
> If many developers (especially of free applications) think likewise
> user will experience a increasing number of non-working applications
> in the Android market.
> But thanks for your reply anyway :-)
>
> Axel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread axel
> You will need to use reflection (or intelligent class loading) and use
> the ContactsContracts provider when running on Android 2.0, allowing
> your existing Contacts code to be used on 1.5/1.6.
The Contacts.ContactMethods API is deprecated but not dropped. And
even deprecated APIs are required to function properly.
Google has to make sure (and even stated it in this forum) that this
is the case. It cannot be the idea for applications to check the
Android version invoke APIs accordingly via reflection.
I don't like to receive complaints from user that my application
doesn't work properly on their phone but if Google doesn't ensure that
event deprecated APIs, it is not my fault.
If many developers (especially of free applications) think likewise
user will experience a increasing number of non-working applications
in the Android market.
But thanks for your reply anyway :-)

Axel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Mark Murphy
Tim Jowers wrote:
> Sweet! Mark. Thanks for covering this. I don't see it solved anywhere
> on the Net or developer.android.com.

A lot of this has been covered on this list before, either in the
context of ContactsContract or more generally in the line of supporting
different Android API versions. However, the notes are still somewhat
scattered.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Consulting/App Development: http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Tim Jowers
Sweet! Mark. Thanks for covering this. I don't see it solved anywhere
on the Net or developer.android.com.

Tim


On Thu, Nov 26, 2009 at 7:42 AM, Mark Murphy  wrote:
> Tim Jowers wrote:
>> Is there an API to determine the phone's version of Android? For now,
>> I'm using try-catch. Sucky but works.
>
> android.os.Build.VERSION.SDK. Or, if you're only worrying about 1.6 and
> newer, use SDK_INT instead of SDK.
>
>> Also, my 2.0 built APK does not run on my G1 phone. Maybe it's
>> something I've done but I haven't dug into it. Maybe that's what you
>> meant by "intelligent" class loading do you mean Class.forName()
>> or Class.loadClass() or whatever its called instead of import
>> blahblh;?
>
> Well, you'll need to look at your stack trace. You can get that from adb
> logcat, DDMS, or the DDMS perspective in Eclipse. IIRC, using a class
> that references 2.0 APIs in a 1.5/1.6 environment will give you a
> VerifyError.
>
> Using Class.forName() is one technique to create an application that can
> use ContactsContract. Or, do something like this:
>
> abstract class ContactsAdapterBridge {
>abstract ListAdapter buildNameAdapter(Activity a);
>abstract ListAdapter buildPhonesAdapter(Activity a);
>abstract ListAdapter buildEmailAdapter(Activity a);
>
>public static final ContactsAdapterBridge INSTANCE=buildBridge();
>
>private static ContactsAdapterBridge buildBridge() {
>int sdk=new Integer(Build.VERSION.SDK).intValue();
>
>if (sdk<5) {
>return(new OldContactsAdapterBridge());
>}
>
>return(new NewContactsAdapterBridge());
>}
> }
>
> This is a fragment of a sample that I'll be uploading to github tomorrow
> sometime (I hope). NewContactsAdapterBridge uses ContactsContract;
> OldContactsAdapterBridge uses Contacts. So long as you don't try
> *loading* a class that uses 2.0 APIs, you won't get a VerifyError. The
> 2.0-referencing class can still be in the APK, though.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Training in US: 11-15 January 2010: http://onlc.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Mark Murphy
Tim Jowers wrote:
> Is there an API to determine the phone's version of Android? For now,
> I'm using try-catch. Sucky but works.

android.os.Build.VERSION.SDK. Or, if you're only worrying about 1.6 and
newer, use SDK_INT instead of SDK.

> Also, my 2.0 built APK does not run on my G1 phone. Maybe it's
> something I've done but I haven't dug into it. Maybe that's what you
> meant by "intelligent" class loading do you mean Class.forName()
> or Class.loadClass() or whatever its called instead of import
> blahblh;?

Well, you'll need to look at your stack trace. You can get that from adb
logcat, DDMS, or the DDMS perspective in Eclipse. IIRC, using a class
that references 2.0 APIs in a 1.5/1.6 environment will give you a
VerifyError.

Using Class.forName() is one technique to create an application that can
use ContactsContract. Or, do something like this:

abstract class ContactsAdapterBridge {
abstract ListAdapter buildNameAdapter(Activity a);
abstract ListAdapter buildPhonesAdapter(Activity a);
abstract ListAdapter buildEmailAdapter(Activity a);

public static final ContactsAdapterBridge INSTANCE=buildBridge();

private static ContactsAdapterBridge buildBridge() {
int sdk=new Integer(Build.VERSION.SDK).intValue();

if (sdk<5) {
return(new OldContactsAdapterBridge());
}

return(new NewContactsAdapterBridge());
}
}

This is a fragment of a sample that I'll be uploading to github tomorrow
sometime (I hope). NewContactsAdapterBridge uses ContactsContract;
OldContactsAdapterBridge uses Contacts. So long as you don't try
*loading* a class that uses 2.0 APIs, you won't get a VerifyError. The
2.0-referencing class can still be in the APK, though.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 11-15 January 2010: http://onlc.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Tim Jowers
Is there an API to determine the phone's version of Android? For now,
I'm using try-catch. Sucky but works.

Also, my 2.0 built APK does not run on my G1 phone. Maybe it's
something I've done but I haven't dug into it. Maybe that's what you
meant by "intelligent" class loading do you mean Class.forName()
or Class.loadClass() or whatever its called instead of import
blahblh;?

For now I'm having to reverse engineer the URI for 2.0 and use it so I
have files which build on 1.5 but run with 2.0.

Thanks!
Tim

On Thu, Nov 26, 2009 at 7:15 AM, Mark Murphy  wrote:
> axel wrote:
>> Back to the original question: Apps working well with 1.5/1.6 are
>> broken with 2.0 - exactly the same problem I have.
>> AFAIK the code below is perfectly valid and should continue to work
>> with 2.0 - unfortunately it does not.
>>
>> String[] returnColumns = new String[] {
>> Contacts.ContactMethods.PERSON_ID,
>> Contacts.ContactMethods.DISPLAY_NAME,
>> Contacts.ContactMethods.KIND,
>> Contacts.ContactMethods.DATA,
>> Contacts.ContactMethods.TYPE
>> };
>>
>> Cursor cursor = activity.managedQuery
>> (Contacts.ContactMethods.CONTENT_URI, returnColumns, null, null,
>> Contacts.ContactMethods.DISPLAY_NAME + " ASC");
>>
>> In 2.0 AVD I always get 0 for cursor.getCount() - in 1.5/1.6 AVD this
>> works well. Of course I have created contacts in the AVD before.
>> If I click on "accounts" in the options menu of the Contacts
>> application if causes a "force close" (doesn't look pretty mature to
>> me).
>> The sad thing is that I have an application on the market and receive
>> complains about "force close" errors when contacts are accessed but
>> I'm unable to reproduce it with AVD.
>
> You will need to use reflection (or intelligent class loading) and use
> the ContactsContracts provider when running on Android 2.0, allowing
> your existing Contacts code to be used on 1.5/1.6.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android Development Wiki: http://wiki.andmob.org
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread Mark Murphy
axel wrote:
> Back to the original question: Apps working well with 1.5/1.6 are
> broken with 2.0 - exactly the same problem I have.
> AFAIK the code below is perfectly valid and should continue to work
> with 2.0 - unfortunately it does not.
> 
> String[] returnColumns = new String[] {
> Contacts.ContactMethods.PERSON_ID,
> Contacts.ContactMethods.DISPLAY_NAME,
> Contacts.ContactMethods.KIND,
> Contacts.ContactMethods.DATA,
> Contacts.ContactMethods.TYPE
> };
> 
> Cursor cursor = activity.managedQuery
> (Contacts.ContactMethods.CONTENT_URI, returnColumns, null, null,
> Contacts.ContactMethods.DISPLAY_NAME + " ASC");
> 
> In 2.0 AVD I always get 0 for cursor.getCount() - in 1.5/1.6 AVD this
> works well. Of course I have created contacts in the AVD before.
> If I click on "accounts" in the options menu of the Contacts
> application if causes a "force close" (doesn't look pretty mature to
> me).
> The sad thing is that I have an application on the market and receive
> complains about "force close" errors when contacts are accessed but
> I'm unable to reproduce it with AVD.

You will need to use reflection (or intelligent class loading) and use
the ContactsContracts provider when running on Android 2.0, allowing
your existing Contacts code to be used on 1.5/1.6.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-26 Thread axel
Back to the original question: Apps working well with 1.5/1.6 are
broken with 2.0 - exactly the same problem I have.
AFAIK the code below is perfectly valid and should continue to work
with 2.0 - unfortunately it does not.

String[] returnColumns = new String[] {
Contacts.ContactMethods.PERSON_ID,
Contacts.ContactMethods.DISPLAY_NAME,
Contacts.ContactMethods.KIND,
Contacts.ContactMethods.DATA,
Contacts.ContactMethods.TYPE
};

Cursor cursor = activity.managedQuery
(Contacts.ContactMethods.CONTENT_URI, returnColumns, null, null,
Contacts.ContactMethods.DISPLAY_NAME + " ASC");

In 2.0 AVD I always get 0 for cursor.getCount() - in 1.5/1.6 AVD this
works well. Of course I have created contacts in the AVD before.
If I click on "accounts" in the options menu of the Contacts
application if causes a "force close" (doesn't look pretty mature to
me).
The sad thing is that I have an application on the market and receive
complains about "force close" errors when contacts are accessed but
I'm unable to reproduce it with AVD.

Axel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-23 Thread Rachel Blackman

On Nov 20, 2009, at 6:09 PM, Padma wrote:

> Rachel:
> 
> My understanding is that the contact Id in the Phone/Email table
> actually refers to the _ID in the ContactsContract.RawContacts table.
> You might want to first get the list of all Raw Contacts associated
> with the particular contact id and then query the Phone table based on
> the RawContact id you have obtained.
> 

I can certainly see that being the case; I'll need to write up a test app later 
to test that theory, I guess.  But if so, that's unfortunate and definitely 
worth documenting in the under-construction FAQ; that would break the model 
established elsewhere in the API of using CONTACT_ID to refer to the ID for the 
combined, virtual contacts and RAW_CONTACT_ID for the IDs of underlying, actual 
service-specific raw contacts.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-23 Thread Padma
Rachel:

My understanding is that the contact Id in the Phone/Email table
actually refers to the _ID in the ContactsContract.RawContacts table.
You might want to first get the list of all Raw Contacts associated
with the particular contact id and then query the Phone table based on
the RawContact id you have obtained.

-Padma.



On Nov 21, 12:16 am, Rachel Blackman  wrote:
> On Nov 20, 2009, at 6:55 AM, Henry wrote:
>
> > Now, it always return just one row. I tried several ways, like
> >   ContactsContract.CommonDataKinds.Email.CONTACT_ID + " in ('1', '2',
> > '3');
> > It always one row.   If I just contact id "3", it will return contact
> > 3.
> > Do you know a way to get all the emails in one single query?
>
> Honestly, given the schema (raw contacts and virtual contacts all stored 
> together), if you just want all email addresses while maintaining any sort of 
> mapping to their respective contacts, I would query all the contacts 
> individually.  (Do a query that returns all the contacts, then a query on 
> each of them to return the emails, eliminating duplicates.)
>
> Am I misunderstanding the usage case?
>
> (I'm hoping to have some time this weekend to work more on the Contacts 2.0 
> FAQ and samples that we've gathered so far, too!)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-20 Thread Rachel Blackman

On Nov 20, 2009, at 6:55 AM, Henry wrote:

> Now, it always return just one row. I tried several ways, like
>   ContactsContract.CommonDataKinds.Email.CONTACT_ID + " in ('1', '2',
> '3');
> It always one row.   If I just contact id "3", it will return contact
> 3.
> Do you know a way to get all the emails in one single query?

Honestly, given the schema (raw contacts and virtual contacts all stored 
together), if you just want all email addresses while maintaining any sort of 
mapping to their respective contacts, I would query all the contacts 
individually.  (Do a query that returns all the contacts, then a query on each 
of them to return the emails, eliminating duplicates.)

Am I misunderstanding the usage case?

(I'm hoping to have some time this weekend to work more on the Contacts 2.0 FAQ 
and samples that we've gathered so far, too!)


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-20 Thread Henry
Rachel:

Your following query is working perfectly for a single contact.
Cursor emails = getContentResolver().query(
 
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID
+ " = " + contactId,
null, null);

However, If I want to get all the contact emails, I will remove the
selection and query is
Cursor emails = getContentResolver().query(
 
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
null,
null,
null, null);
Now, it always return just one row. I tried several ways, like
   ContactsContract.CommonDataKinds.Email.CONTACT_ID + " in ('1', '2',
'3');
It always one row.   If I just contact id "3", it will return contact
3.
Do you know a way to get all the emails in one single query?

Thanks a lot for your help, and your suggestion to put sample projects
for 2.0 contact api is
really helpful.

Henry


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to get all contact's name phone number, email for 2.0

2009-11-19 Thread Henry
Really appreciated!!!  I tried and worked.
Here is the original query I used for 1.6:

String[] PROJECTS = new String[] { People._ID,
People.DISPLAY_NAME,
People.NAME, People.NUMBER, 
People.PRIMARY_EMAIL_ID };
Cursor cursor = getContentResolver().query(People.CONTENT_URI,
PROJECTS, null, null, People.NAME);
startManagingCursor(cursor);

if (cursor == null) {
return;
}

if (!cursor.moveToFirst()) {
cursor.close();
return;
}

int mIdIndex = cursor.getColumnIndex(People._ID);
int mNameIndex = cursor.getColumnIndex(People.DISPLAY_NAME);
int mNumberIndex = cursor.getColumnIndex(People.NUMBER);
int mEmailIdIndex = 
cursor.getColumnIndex(People.PRIMARY_EMAIL_ID);

HashMap hash = new HashMap();
try {
do {
long id = cursor.getLong(mIdIndex);
String name = cursor.getString(mNameIndex);
String phone = cursor.getString(mNumberIndex);
}
 }
}
  }

-- Henry

On Nov 13, 12:19 pm, Rachel Blackman  wrote:
> On Nov 13, 2009, at 3:33 AM, Jeff Sharkey wrote:
>
> > Could you paste the exact query() that is returning empty for you?
>
> > Since all data is now stored in a single table you should be able to
> > query on Data.CONTENT_URI and filter by Data.MIMETYPE to match the two
> > types you're looking for.
>
> I honestly get the feeling that the new 2.0 contacts API could use better 
> documentation.  I've had my own little issues to sort out, and a lot of my 
> working with the ContactsContract API seems to be writing tiny test programs 
> to figure out 'okay, is THIS how this works...?  No...?  Hrm... okay, how 
> about... no, well, that broke everything.  Let's rebuild the emulator...'
>
> However, to share with the original poster, here's my best in-the-mail-client 
> attempt at a quick bit of 'let's read all the phone numbers and emails for 
> each contact.'  (I'm sure if I mucked this up, someone else can post a 
> corrected one.)
>
> 
>         // Let's walk our address book.  I apologize for any typos, since 
> this was
>         // written in an e-mail client, rather than an editor!  Hopefully I 
> did
>         // get this right...
>         //
>         Cursor cursor = 
> getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
>                                                     null, null, null, null);
>         while (cursor.moveToNext()) {
>             String contactId = cursor.getString(cursor.getColumnIndex(
>                                             ContactsContract.Contacts._ID));
>             String hasPhone = cursor.getString(cursor.getColumnIndex(
>                                             
> ContactsContract.Contacts.HAS_PHONE_NUMBER));
>
>             if (Boolean.parseBoolean(hasPhone)) {
>                 // We have a phone number, so let's query this:
>
>                 Cursor phones = getContentResolver().query(
>                           ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
>                           null,
>                           ContactsContract.CommonDataKinds.Phone.CONTACT_ID 
> +" = "+ contactId,
>                           null, null);
>
>                 while (phones.moveToNext()) {
>                     // Get the phone number.  If your contact has combined 
> several
>                     // raw contacts, you might get a duplicated number. (I 
> think?)
>                     //
>                     String phoneNumber = phones.getString(
>                                             phones.getColumnIndex(
>                                                     
> ContactsContract.CommonDataKinds.Phone.NUMBER));
>
>                     [ ... do something with phone number here ... ]           
>                          
>                 }
>                 phones.close();
>             }
>
>             Cursor emails = getContentResolver().query(
>                     ContactsContract.CommonDataKinds.Email.CONTENT_URI,
>                     null,
>                     ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " 
> + contactId,
>                     null, null);
>
>             while (emails.moveToNext()) {
>                 // Like phone numbers, if your contact has combined several
>                 // raw contacts, you can get the same e-mail address more than
>                 // once.
>                 //          
>                 String emailAddress = emails.getString(
>                                         emails.getColumnIndex(
>                                                 
> ContactsContract