Contacts photo is not displayed in Android?
<p>Hi 
I have a problem in displaying the contacts image in android.
Following is the code snippet I have used,</p>

<pre><code>public String getCallersInfo(ContentResolver cnt,String phoneNumber)
{
    mContentResolver = cnt;
    lNumber = phoneNumber;

    System.out.println("Start test");

    Cursor l_Cur = mContentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                                          null, 
                                          ContactsContract.CommonDataKinds.Phone.NUMBER +" = ?", 
                                          new String[]{lNumber }, null);
    while (l_Cur.moveToNext()) 
    {
        cid = l_Cur.getString(l_Cur.getColumnIndex(
                    ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
    }
    System.out.println("The contact ID for person with phone number "+ lNumber + " is " + cid); 

    if(!(cid.equals("Unknown"))) 
    {         
        Cursor cursor_contacts = mContentResolver.query(ContactsContract.Contacts.CONTENT_URI,
                                                        null, 
                                                        ContactsContract.Contacts._ID + " = ?", 
                                                        new String[]{cid }, 
                                                        null);
        while(cursor_contacts.moveToNext()) 
        {
            displayname = cursor_contacts.getString(cursor_contacts.getColumnIndex( 
                          ContactsContract.Contacts.DISPLAY_NAME));
            photoid = cursor_contacts.getString(cursor_contacts.getColumnIndex( 
                          ContactsContract.Contacts.PHOTO_ID));

        }
        System.out.println("The display name &amp; photo id for person with phone number "
                        + lNumber + " is " + displayname + " &amp; " + photoid); 

        Uri contactPhotoUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Integer.parseInt(cid));

       // Uri photoUri = Uri.withAppendedPath(contactPhotoUri, Contacts.Photo.CONTENT_DIRECTORY);

        // contactPhotoUri --&gt; content://com.android.contacts/contacts/1557

        InputStream photoDataStream = Contacts.openContactPhotoInputStream(mContentResolver,contactPhotoUri); // &lt;-- always null

        if(photoDataStream == null)
        {
            System.out.println("No photo available ");
        }

        Bitmap bt = BitmapFactory.decodeStream(photoDataStream);

        setmPhoto(bt);
    }
    return displayname;
}
</code></pre>

<p>Thanks in advance.</p>
