3

I use a contentResolver Query on my Android Studio Emulator. I put the mp3 files in the downloads folder, where I can see them int the android studio device file explorer and in den device exporer in the emulator. I can't fetch the files using contentResolver Query.

String sortOder = MediaStore.Audio.Media.TRACK + " ASC";
cur = getContentResolver().query(uri, null, null, null, sortOder);

The ContentResolver is searching for content://media/external/audio/media

I restarted the emulator, removed and installed the app after upload.

On real devices this resolver works, but not on the emulator. Why does the contentResolver on the emulator doesn't find the uploaded files.

Thanks GGKenter image description here

  • Presumably, they have not been indexed by the `MediaStore`. – CommonsWare Jan 03 '20 at 23:44
  • ok, and how to index them? though recreation of the app does new indexing – GGK stands for Ukraine Jan 03 '20 at 23:46
  • Eventually, they should get indexed. You could try rebooting the emulator (simulating a real reboot, not just closing and reopening the window) and see if they get reindexed automatically. Normally, the code that puts the files out on external storage will index them at that point. – CommonsWare Jan 03 '20 at 23:54
  • no, rebooting the emulator doesn't reindexing. Problem persists – GGK stands for Ukraine Jan 04 '20 at 00:15
  • You can try [a solution like this](https://stackoverflow.com/a/43902912/115145) to reindex via `adb`. – CommonsWare Jan 04 '20 at 00:20
  • I've tried these solutions... but I got a Permission Denial error (not allowed to broadcast). I don't think my problem is due to the non-indexed mediastore because the emulator exporter finds the files. – GGK stands for Ukraine Jan 04 '20 at 18:12
  • Problem problem only occurs under API29. I have created a new entry for this ( https://stackoverflow.com/questions/59586601/contentresolver-running-on-emulator-cant-find-mp3-files – GGK stands for Ukraine Jan 11 '20 at 23:08

1 Answers1

1

You should reboot your devices if you just dragged your files into the sdcard in Android Studio. It's not updated immediately.

Chinese Cat
  • 5,359
  • 2
  • 16
  • 17