title: Write External Storage Permission is always denied
body: <p>I'm using Download Manager to Download Image in my android app.</p>
  <p>To obtain the &quot;WRITE_EXTERNAL_STORAGE&quot; permission I'm suing <a href="https://github.com/Karumi/Dexter" rel="nofollow noreferrer">Dexter</a> library.</p>
  <pre><code>        Dexter.withContext(getApplicationContext())
              .withPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
              .withListener(new PermissionListener() {
                  @Override
                  public void onPermissionGranted(PermissionGrantedResponse permissionGrantedResponse) {
                      Toast.makeText(LiveTaskActivity.this, &quot;Granted&quot;, Toast.LENGTH_SHORT).show();
                  }
  
                  @Override
                  public void onPermissionDenied(PermissionDeniedResponse permissionDeniedResponse) {
                      Toast.makeText(LiveTaskActivity.this, &quot;Denied&quot;, Toast.LENGTH_SHORT).show();
                  }
  
                  @Override
                  public void onPermissionRationaleShouldBeShown(PermissionRequest permissionRequest, PermissionToken permissionToken) {
  
                  }
              }).check();
  </code></pre>
  <p>But always I get permission &quot;Denied&quot; even I manually accept the permission to grant the permission from the app. I also tried manually implementing the permission request code.</p>
  <pre><code>        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
              || ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
  
          ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
      } else {
          download();
      }
  </code></pre>
  <p>Still, I can't get the permission. Here is the Manifest Code:</p>
  <pre><code>    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
  
      &lt;application
        android:requestLegacyExternalStorage=&quot;true&quot;
  </code></pre>
  <p>Here is my buil.gradle(app) code:</p>
  <pre><code>android {
  compileSdkVersion 30
  buildToolsVersion &quot;30.0.3&quot;
  
  defaultConfig {
      applicationId &quot;app.gigg.me.app&quot;
      minSdkVersion 22
      targetSdkVersion 30
      versionCode 2
      versionName '1.0.1'
  </code></pre>
  <p>Please help me to solve this problem.</p>
  <p>**Update Here is my download code</p>
  <pre><code>    private void startDownload() {
      Toast.makeText(this, &quot;Downloading File...&quot;, Toast.LENGTH_SHORT).show();
      fileName = link.substring(link.lastIndexOf(&quot;/&quot;) + 1) + &quot;.png&quot;;
      File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath(), fileName);
      DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link))
              .setTitle(fileName)
              .setDescription(&quot;Downloading&quot;)
              .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
              .setDestinationUri(Uri.fromFile(file))
              .setMimeType(&quot;image/*&quot;)
              .setAllowedOverMetered(true)
              .setAllowedOverRoaming(true);
      download_id = downloadManager.enqueue(request);
  }
  </code></pre>