title: I have permissions and still get the java.io.FileNotFoundException: open failed: EACCES (Permission denied)
body: <p>I'am targeting SdkVersion 29 and I'm trying to play a song located in my external storage sdCard but it keep showing this error :</p>
  <pre><code>W/System.err: java.io.FileNotFoundException: /storage/E0FD-1813/Music/3_INTRO.mp3: open failed: EACCES (Permission denied)
  
  V/MediaPlayerNative: isPlaying: no active player
  I/chatty: uid=10325(com.android.leafter) Thread-6 identical 32 lines
  V/MediaPlayerNative: isPlaying: no active player
  V/MediaPlayerNative: isPlaying: no active player
  I/chatty: uid=10325(com.android.leafter) Thread-6 identical 26 lines
  
  </code></pre>
  <p>i have a fragment called musicfragment that contains a listview that will hold the songs when the getSongs method is triggered but i know that i sould have permession so I added the read external storage</p>
  <p>manifest.xml :</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.android.leafter&quot;&gt;
  
      &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;&gt;&lt;/uses-permission&gt;
  </code></pre>
  <p>here i implemented the runtime permission :</p>
  <pre><code>public class MusicFragment extends Fragment {
  
  //    ------------------------------- Permission ----------------------------------------------------
      private ActivityResultLauncher&lt;String&gt; requestPermissionLauncher =
              registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -&gt; {
                  if (isGranted) {
                      Toast.makeText(getContext(),&quot;permission is granted&quot;,Toast.LENGTH_SHORT).show();
                      getSongs();
  
                  } else {
                      Toast.makeText(getContext(),&quot;permission not granted&quot;,Toast.LENGTH_SHORT).show();
                  }
              });
  //    ------------------------------- END Permission ----------------------------------------------------
      private static final int REQUEST_PERMISSION_CODE = 99;
      public MusicFragment() {
          // Required empty public constructor
      }
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View musicFragmentView = inflater.inflate(R.layout.fragment_music, container, false);
  
          listSongs = new ArrayList&lt;&gt;();
          songAdapter = new SongAdapter(getContext(), listSongs);
  
          lvSongs = (ListView) musicFragmentView.findViewById(R.id.lvSongs);
          lvSongs.setAdapter(songAdapter);
  //----------------------------------------------------- PERMISSION SECTION ---------------------------
  
          if (ContextCompat.checkSelfPermission(
                  getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) ==
                  PackageManager.PERMISSION_GRANTED) {
              Toast.makeText(getContext(),&quot;Already granted&quot;,Toast.LENGTH_SHORT).show();
              getSongs();
          } else {
              requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE);
              Toast.makeText(getContext(),&quot;request sent&quot;,Toast.LENGTH_SHORT).show();
          }
  
          lvSongs.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
                  Song currentSong = listSongs.get(position);
  
                  Intent musicPlayerIntent = new Intent(getContext(), MusicPlayer_Activity.class);
                  musicPlayerIntent.putExtra(&quot;currentSong&quot;, currentSong);
                  startActivity(musicPlayerIntent);
              }
          });
  
          return musicFragmentView;
      }
  //----------------------------------------------------- PERMISSION SECTION ----------------------------
      private void getSongs() {
          // get songs from external storage
      }
  }
  </code></pre>
  <p>then in the musicPlayer activity i retrieve the current song from the intent</p>
  <pre><code>public class MusicPlayer_Activity extends AppCompatActivity implements View.OnClickListener {
  
  //    Views delcaration
  
      TextView tvTime, tvDuration, songTitle, songArtist;
      Button btnPlay;
      SeekBar seekBarTime, seekBarVolume;
  
      MediaPlayer musicPlayer;
      AudioManager audiomanager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_music_player_);
        // Views declaration ...
        
          Song currentSong = (Song) getIntent().getSerializableExtra(&quot;currentSong&quot;);
  
          songTitle.setText(currentSong.getTitle());
          songArtist.setText(currentSong.getArtist());
  
          musicPlayer = new MediaPlayer();        
          try {
              musicPlayer.setDataSource(&quot;file://&quot;+currentSong.getPath());
              Toast.makeText(this,&quot;after setDataSource file://&quot;+currentSong.getPath(),Toast.LENGTH_SHORT).show();
              musicPlayer.prepare();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          btnPlay.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View view) {
          if (view.getId() == R.id.btnPlay) {
              if (musicPlayer.isPlaying()) {
                  musicPlayer.pause();
                  btnPlay.setBackgroundResource(R.drawable.ic_play);
              } else {
                  musicPlayer.start();
                  btnPlay.setBackgroundResource(R.drawable.ic_pause);
              }
          }
      }
  }
  </code></pre>
  <p>but when i run the app on the songs don't get played and i get the error shown above</p>
  <p><strong>PS :  i tried to put a .mp3 song as a resource in the raw folder and use MediaPlayer.create(getApplicationContext(), R.raw.song) and it works</strong></p>