0

I've made an image gallery activity that is needed for my app. All works well except that it shows an image album for every music album I have in my SD card that contains album art. The default gallery app manages to hide these albums-pictures. How can I achieve the same ?

I get image albums with this code:

    Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_ID,
            MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.DATA };
    Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
    ArrayList<String> ids = new ArrayList<String>();
    if (cursor != null) {
        while (cursor.moveToNext()) {
            PhotoAlbum album = new PhotoAlbum();
            int columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID);
            album.id = cursor.getString(columnIndex);

            if (!ids.contains(album.id)) {
                //get album name
                columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
                album.name = cursor.getString(columnIndex);
                //get image id for the album cover
                columnIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);
                album.coverID = cursor.getInt(columnIndex);
                //get filename of album cover image
                columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
                album.fileName=new File(cursor.getString(columnIndex)).getParentFile().getAbsolutePath(); 
                album.count++;     albumList.add(album);      ids.add(album.id);    album.bm=null;


            } else { albumList.get(ids.indexOf(album.id)).count++; }
        }
        cursor.close();
    }
Anonymous
  • 4,470
  • 3
  • 36
  • 67
  • 1
    Maybe you can strip the coverarts using ALBUM_ART column and one good SQL statement. Just an idea. See: http://developer.android.com/reference/android/provider/MediaStore.Audio.AlbumColumns.html#ALBUM_ART – Zielony Nov 25 '14 at 22:29
  • How are these album art files recognisable? The usual way to hide images for the Gallery app is to put a file with the name .nomedia in the same folder. So inspect if that file is there. – greenapps Nov 25 '14 at 23:38
  • That would hide these images from every app and that's not good practice. – Anonymous Nov 25 '14 at 23:55
  • The ALBUM_ART column sounds promising...do you have a suggestion on how I would use it in the selection arguments of the cursor ? Unfortunately me and SQL don't get along very well ! I tried a few things but didn't have any luck – Anonymous Nov 25 '14 at 23:56

0 Answers0