Android get a cursor only with contacts that have an email listed >android 2.0

@CapDroid Fixed working code from DArkO’s post: ContentResolver cr = context.getContentResolver(); String[] PROJECTION = new String[] { ContactsContract.RawContacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_ID, ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Photo.CONTACT_ID }; String order = “CASE WHEN ” + ContactsContract.Contacts.DISPLAY_NAME + ” NOT LIKE ‘%@%’ THEN 1 ELSE 2 END, ” + ContactsContract.Contacts.DISPLAY_NAME + “, ” + ContactsContract.CommonDataKinds.Email.DATA + ” COLLATE NOCASE”; String filter … Read more

Retrieve all contacts phone numbers in iOS

Try this it works for iOS 6 as well as iOS 5.0 or older: Sample Project Demo First add the following frameworks in Link Binary With Libraries AddressBookUI.framework AddressBook.framework Then Import #import <AddressBook/ABAddressBook.h> #import <AddressBookUI/AddressBookUI.h> Then use the following code Requesting permission to access address book ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL); __block BOOL accessGranted = … Read more

Android contacts Display Name and Phone Number(s) in single database query?

Try this code: Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}; Cursor people = getContentResolver().query(uri, projection, null, null, null); int indexName = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); int indexNumber = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); if(people.moveToFirst()) { do { String name = people.getString(indexName); String number = people.getString(indexNumber); // Do work… } while (people.moveToNext()); }

get contact info from android contact picker

Phone Numbers Phone numbers are stored in their own table and need to be queried separately. To query the phone number table use the URI stored in the SDK variable ContactsContract.CommonDataKinds.Phone.CONTENT_URI. Use a WHERE conditional to get the phone numbers for the specified contact. if (Integer.parseInt(cur.getString( cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) { Cursor pCur = cr.query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, … Read more

Read all contacts’ phone numbers in android

Following code shows an easy way to read all phone numbers and names: Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null); while (phones.moveToNext()) { String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } phones.close(); NOTE: getContentResolver is a method from the Activity context.

Programmatically Request Access to Contacts

As per this documentation on apple’s site (scroll down to Privacy in the middle of the page), access to the address book must be granted before it can be access programmatically. Here is what I ended up doing. #import <AddressBookUI/AddressBookUI.h> // Request authorization to Address Book ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL); if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) … Read more

How to read contacts on Android 2.0

First, ensure that you have added <uses-permission android:name=”android.permission.READ_CONTACTS”/> to your AndroidManifest.xml file, then you can loop through your phone contacts like this: 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)) { // You know it has a number so now query it … Read more

How to call Android contacts list?

I’m not 100% sure what your sample code is supposed to do, but the following snippet should help you ‘call the contacts list function, pick a contact, then return to [your] app with the contact’s name’. There are three steps to this process. 1. Permissions Add a permission to read contacts data to your application … Read more