How to Get Contact Image in Android.

By | November 11, 2012

This simple example gets the image from contacts in android.

private void getContactsDetails() {

		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 Number = phones
					.getString(phones
							.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

			String image_uri = phones
					.getString(phones
							.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));

			System.out.println("Contact1 : " + Name + ", Number " + Number
					+ ", image_uri " + image_uri);
 
			
			if (image_uri != null) {
			     image.setImageURI(Uri.parse(image_uri));
		        }
			

		}

Please leave your valuable comments.

3 thoughts on “How to Get Contact Image in Android.

  1. Nauman Zubair

    Hi, I tried your code but no image displayed. Can you tell me how to display facebook contact images in android listview.

    Reply
  2. syam

    in gingerbread contact image is crashing .getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI))

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *