title: Getting contact photo
body: <p>I am having a problem getting a contact photo, the kind you see in the messaging app and new gmail notification. I have looked at a few example codes but nothing has worked for me, this is what I currently have</p>
  
  <p>this should get the photo uri and turn it into a bitmap image to use or at least it seems</p>
  
  <pre><code>public static Bitmap getContactImage(long id,Context context){
      InputStream input = getPhoto(id,context);
      if(input == null){
          return null;
      }
      return BitmapFactory.decodeStream(input);
  }
  
  public static InputStream getPhoto(long contactId,Context context){
      Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
      Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
      InputStream in = null;
      try{
          in = context.getContentResolver().openInputStream(photoUri);
      }catch(FileNotFoundException e){
          Log.d(TAG, e.toString());
      }
      return in;
  }
  </code></pre>
  
  <p>and this is how I call</p>
  
  <pre><code>long contactID = 0;
                  Bitmap image = BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_contact_picture);
                  Cursor contact = context.getContentResolver().query(Data.CONTENT_URI,new String[] {Data.CONTACT_ID},Email.ADDRESS  + "='" + from + "'",null,null);
                  if(contact.moveToFirst() &amp;&amp; contact != null){
                      contactID = contact.getLong(0);
                      image = getContactImage(contactID,context);
                  }
  </code></pre>
  
  <p>I get the contact id fine (checked by searching the number for the person querying against) but then it does not find the contact photo. I know there is a photo because I am testing it against myself to make sure and I have a contact photo so I dont know what else I should do. </p>
  
  <p>I always find navigating the contact provider very troublesome because there is so much to it.</p>