Last updated on May 26th, 2015 at 10:08 pm

In this tip learn how to get image from android contact list in your app.

String imnage;
Cursor phonesCursor;
Urls urls;

// Get image from phone no
 try {
            Uri phoneUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode("Phone number"));
            phonesCursor = context.getContentResolver().query(phoneUri, new String[]{ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI}, null, null, null);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
        catch (IllegalArgumentException e){
            e.printStackTrace();
        }
        if (phonesCursor != null && phonesCursor.moveToFirst()) {
            imnage = phonesCursor.getString(0);
            imageView=(ImageView)findViewById(R.id.image);
            try {
                imageView.setImageURI(Uri.parse(imnage));
                Log.e("detail", "==============" + imnage);
            }catch (NullPointerException e){
                e.printStackTrace();
            }
            // displayName = phonesCursor.getString(0); // this is the contact name
        } else {
            Log.e("no contact ", "============");
        }

thank you 🙂