I am having a bear of a time figuring out what colums exist for email
contact methods.  Specifically, I want to find out the "home", "work"
or "other" of an email address.

I have tried looking for it under integer "TYPE" (illegal column), and
under Strings "LABEL" (illegal column) and "NAME" (this works, but it
is the owner/person's name, not the name of the email address).

Is there a place where these schemas (as they are actually used) is
documented well?  the Javadocs seem to mislead me.

// try to find email addresses for person with ID == personId

          Cursor cursor = activity.getContentResolver().query(
                                Contacts.ContactMethods.CONTENT_EMAIL_URI,
                        new String[] { Contacts.ContactMethods.TYPE,
Contacts.ContactMethods.DATA },
                        Contacts.ContactMethods.PERSON_ID + "= " +
personId,
                        null,
                        null);

                if (cursor.getCount() >= 1) {

                    int labelCol = cursor.getColumnIndexOrThrow
(Contacts.ContactMethods.TYPE);
                    int addressCol = cursor.getColumnIndexOrThrow
(Contacts.ContactMethods.DATA);

                        cursor.moveToFirst();
                    do {
                            String email = cursor.getString(addressCol);
                            //String label = cursor.getString(labelCol);
                            int label = cursor.getInt(labelCol);

                            if (Config.DEBUG) Log.d(TAG, "address for email
is " + email);

                            if (email != null && email.length() > 0) {
                                    intent = new Intent(Intent.ACTION_SENDTO,
Uri.parse("mailto://"; + email));

                                        
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                        addIntent(intents, intent, literal, 
false, score);
                            }
                    } while (cursor.moveToNext());
                }
                cursor.close();

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

Reply via email to