Ungureanu Liviu Ungureanu Liviu - 9 months ago 39
Android Question

How can i get the album art from MediaStore?

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){
Log.e(TAG, "am gasit " + c.getString(0) + " " + c.getString(1));
Log.e(TAG, "No image");

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

Thank you!


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());