Cannot access /storage/emulated/0/Music

Viewed 1462

I am trying to create a simple music player app, but my problem is that i am unable to access my Music folder on the internal storage:

File musicFolder = new File(Environment.getExternalStorageDirectory().getPath()+"/Music");
    if(musicFolder.isDirectory()){
        for(File f : musicFolder.listFiles()){

It works till musicFolder.listFiles() which return null. The path it is trying to access is /storage/emulated/0/Music

In the manifest of my app i declared:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Also the canRead() function of musicFolder returns false?

Does anybody know what i am doing wrong?

Edit:

I now get the music files via MediaStore... that works! But playback using MediaPlayer still tells me: Permission Denied when i try to open a music file. I verified i have READ_EXTERNAL_STORAGE permission at runtime.

0 Answers
Related