title: App Crashes throwing an exception of permission denial:reading com.android.providers.media.MediaProvider
body: <p>I am developing an app which needs permission to read and write External Storage.i have write all the permissions in Manifest file as well as also in my java activity file but my app still got crashed as soon as it starts 
   with throwing an Exception of </p>
  
  <p><code>permission denial:reading com.android.providers.media.MediaProvider</code></p>
  
  <blockquote>
    <p>Manifest File</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.abhi.scrolling_tab"&gt;
  
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt;
  &lt;uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"&gt;&lt;/uses-permission&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MainActivity"
          android:exported="true"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Fragment_one"
          android:label="Fragment_one"
          android:theme="@style/AppTheme.NoActionBar" /&gt;
      &lt;activity
          android:name=".Fragment_two"
          android:label="@string/title_activity_fragment_two"
          android:theme="@style/AppTheme.NoActionBar" /&gt;
      &lt;activity
          android:name=".Fragment_three"
          android:label="@string/title_activity_fragment_three"
          android:theme="@style/AppTheme.NoActionBar"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <blockquote>
    <p>Java File</p>
  </blockquote>
  
  <pre><code>public class Fragment_two extends Fragment {
  private RecyclerView recyclerView2;
  private List&lt;Model1&gt; modelList;
  private myAdapter2 adapter;
  private MenuItem menu;
  
  
  public Fragment_two() {
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.activity_fragment_two, container, false);
      ;
      recyclerView2 = (RecyclerView) view.findViewById(R.id.recycle2);
      int No_of_coloumns = 3;
      recyclerView2.setLayoutManager(new GridLayoutManager(getContext(), No_of_coloumns));
      modelList = getAllaudiofromdevice();
      adapter = new myAdapter2(modelList, (ViewGroup) view);
      recyclerView2.setAdapter(adapter);
      return view;
  }
  
  public List&lt;Model1&gt; getAllaudiofromdevice() {
      List&lt;Model1&gt; files = new ArrayList&lt;&gt;();
      try {
          ContentResolver contentResolver = getContext().getContentResolver();
          String selection = MediaStore.Audio.Media.IS_MUSIC;
          Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
          String[] projection = {MediaStore.Audio.AudioColumns.DATA, MediaStore.Audio.AudioColumns.ALBUM, MediaStore.Audio.AudioColumns.ARTIST};
          Cursor c = contentResolver.query(uri, null, selection, null, null);
          if (c != null) {
              while (c.moveToNext()) {
                  Model1 model1 = new Model1();
                  String path = c.getString(0);
                  String album = c.getString(1);
                  String artist = c.getString(2);
                  String name = path.substring(path.lastIndexOf('/') + 1);
                  model1.setName(name);
                  model1.setArtist(artist);
                  model1.setAlbum(album);
                  model1.setPath(path);
                  files.add(model1);
              }
              c.close();
          }
      } catch (Exception e) {
          throw e;
      }
      check();
      return files;
  }
  
  public void check() {
      if (Build.VERSION.SDK_INT &gt;= 23) {
          if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
              requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 123);
              return;
          }
      } else {
          getAllaudiofromdevice();
      }
  }
  
  @Override
  public void onRequestPermissionsResult(int requestcode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      switch (requestcode) {
          case 123:
              if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
                  getAllaudiofromdevice();
              } else {
                  Toast.makeText(getContext(), "you have to set permissions", Toast.LENGTH_SHORT).show();
                  check();
              }
          default:
              super.onRequestPermissionsResult(requestcode, permissions, grantResults);
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please help me to get out of this.
  Thanks in the anticipation.</p>