public void getNumber(ContentResolver cr) { Cursor phones = null; try { phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); int phoneNumberIdx = phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); if (phones.moveToFirst()) { do { String phoneNumber = phones.getString(phoneNumberIdx); phoneList.add(phoneNumber.replaceAll("\\D+", "")); } while (phones.moveToNext()); } } catch (Exception e) { Logger.e(TAG, e.getMessage()); } finally { if (phones != null) { phones.close(); } } }
public void getEmail(ContentResolver cr) { Cursor emails = null; try { emails = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, null, null, null); int emailAddressIdx = emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS); if (emails.moveToFirst()) { do { String phoneNumber = emails.getString(emailAddressIdx); emailList.add(phoneNumber); } while (emails.moveToNext()); } } catch (Exception e) { Logger.e(TAG, e.getMessage()); } finally { if (emails != null) { emails.close(); } } }