Hi I am developing a contact based application in that i want get the email id from the contacts to my application
I am developing the application for android 1.6
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
int index = 0;
if (cur.getCount() > 0) {
emailNames = new String[cur.getCount()];
emailNumbers = new String[cur.getCount()];
while (cur.moveToNext()) {
String id = cur.getString(cur
.getColumnIndex(ContactsContract.Contacts._ID));
name = cur
.getString(cur
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
emailNames[index] = name;
Cursor emails = getContentResolver().query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID
+ " = " + id, null, null);
while (emails.moveToNext()) {
// This would allow you get several email addresses
String emailAddress = emails
.getString(emails
.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
Log.v("email==>", emailAddress);
emailNumbers[index] = emailAddress;
}
}
emails.close();
index++;
}
cur.close();