title: java.io.FileNotFoundException Permission Denied when saving image
body: <pre><code>private void saveImage(Bitmap bitmap){
      try {
          String path = Environment.getExternalStorageDirectory().toString();
          Toast.makeText(getActivity(), path, Toast.LENGTH_SHORT).show();
          OutputStream fOut = null;
          File file = new File(path, mWallpaper.getId().toString() + ".jpg");
          fOut = new FileOutputStream(file);
  
          bitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
          fOut.flush();
          fOut.close();
  
          MediaStore.Images.Media.insertImage(getActivity().getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
      } catch (MalformedURLException e) {
          Toast.makeText(getActivity(), "Error saving wallpaper. MAL", Toast.LENGTH_SHORT).show();
      } catch (IOException e1) {
          Toast.makeText(getActivity(), "Error saving wallpaper.", Toast.LENGTH_SHORT).show();
          e1.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I added this to my AndroidManifests:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>I am trying to save an image to /storage/emulated/0/.</p>
  
  <p>EDIT</p>
  
  <pre><code>int permissionCheck = ContextCompat.checkSelfPermission(getActivity(),
              Manifest.permission.WRITE_EXTERNAL_STORAGE);
      if (ContextCompat.checkSelfPermission(getActivity(),
              Manifest.permission.WRITE_EXTERNAL_STORAGE)
              != PackageManager.PERMISSION_GRANTED) {
  
          if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
                  Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
  
          } else {
  
              ActivityCompat.requestPermissions(getActivity(),
                      new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                      permissionCheck);
          }
      }
  </code></pre>
  
  <p>I've added this to onCreate() for my fragment but I still not a request.</p>