Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI for cover lookups

MediaStore.Audio.Media.getContentUriForPath() seems to return strange results on some phones and lookups to non-external databases are pretty unlikely anyway.
This commit is contained in:
Adrian Ulrich 2017-01-22 20:41:01 +01:00
parent 555070a7e7
commit 2c5abc352c

View File

@ -447,10 +447,9 @@ public class CoverCache {
if (inputStream == null && (CoverCache.mCoverLoadMode & CoverCache.COVER_MODE_ANDROID) != 0) {
long albumId = -1;
ContentResolver res = mContext.getContentResolver();
Uri contentUri = MediaStore.Audio.Media.getContentUriForPath(song.path);
// Lookup the album id assigned to this path in the android media store
Cursor cursor = res.query(contentUri, new String[]{ MediaStore.Audio.Media.ALBUM_ID }, MediaStore.Audio.Media.DATA+"=?", new String[] { song.path }, null);
Cursor cursor = res.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{ MediaStore.Audio.Media.ALBUM_ID }, MediaStore.Audio.Media.DATA+"=?", new String[] { song.path }, null);
if (cursor.moveToFirst()) {
albumId = cursor.getLong(0);
}