tags:

views:

255

answers:

1

Hi!

How can I get the album art from MediaStore? I try something like:

String[] projectionImages = new String[]{MediaStore.Audio.Albums.ALBUM_ART, MediaStore.Audio.Albums.ALBUM_KEY};

      Cursor c = contentResolver.query(MediaStore.Audio.Albums.INTERNAL_CONTENT_URI, projectionImages, null, null, null);

     if(c != null){
      c.moveToFirst();
      Log.e(TAG, "am gasit " + c.getString(0) + " " + c.getString(1));
     }
     else{
      Log.e(TAG, "No image");
     }

but is not working.. I retrive just null for every entry!

Thank you!

+1  A: 

Does it iterate over the amount of entries you see in the directory or do the numbers not match up?

The following works for me when searching for images in teh MediaStore

if (cursor.moveToFirst()) {
do {
int col = cursor.getColumnIndex(Images.Media.DESCRIPTION);
String description = cursor.getString(col);
if (new Long(item).toString().equals(description)) {
imageId = cursor.getPosition();
int dataColumn = cursor.getColumnIndex(Images.Media.DATA);
filePath = cursor.getString(dataColumn);
return true;
}
} while (cursor.moveToNext());
steve