Android ContentResolver can't find any audio files on some devices

Viewed 364

Some users told me, that my audio app doesn't find any audio files on their devices. I use mediastore query and contentResolverto get the ID or path from the audio files.

I don't believe, that I have a problem in my code, so the question is, if mediastore or contentResolverdepends on devices?

Here is an example how I did searching for devices with Android lower Q:

Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
projection = new String[]{
             MediaStore.Audio.Media._ID,
             MediaStore.Audio.Media.ALBUM,
             MediaStore.Audio.Media.ARTIST,
             MediaStore.Audio.Media.DURATION,
             MediaStore.Audio.Media.TITLE,
             MediaStore.Audio.Media.DATA,
             MediaStore.Audio.Media.TRACK,
             MediaStore.Audio.Media.YEAR,
             MediaStore.Audio.Media.DATE_ADDED
};

String sortOder = MediaStore.Audio.Media.TRACK + " ASC";
selection = MediaStore.Audio.Media.DATA + " like ?";
selectionArgs = new String[]{directory};
Cursor cur = getContentResolver().query(uri, projection, selection, selectionArgs, sortOder);

Can someone give me a hint or has had a similar experience? On development devices this behavior doesn't happen, so that no log is available.

0 Answers
Related