title: java.io.FileNotFoundException file path open failed: EPERM (Operation not permitted)
body: <p>This is my code i am trying to download file in local storage but</p>
  <pre><code> private String downloadFile(String MY_URL) {
              int count;
      
              try {
                  URL url = new URL(MY_URL);
                  URLConnection connection = url.openConnection();
                  connection.connect();
                  long startTime = System.currentTimeMillis();
      
                  int lengthOfFile = connection.getContentLength();
                  InputStream input = new BufferedInputStream(url.openStream(), 8192);
                  fileName = MY_URL.substring(MY_URL.lastIndexOf('/') + 1, MY_URL.length());
                  File outputFile = new File(directory, fileName);
                  OutputStream output = new FileOutputStream(outputFile);
      
                  byte data[] = new byte[1024];
      
                  long total = 0;
      
                  while ((count = input.read(data)) != -1) {
                      total += count;
      
                      int status = (int) ((total * 100) / lengthOfFile);
                      output.write(data, 0, count);
      
                      handler.post(new Runnable() {
                          @Override
                          public void run() {
                              // Connectivity Manager
      
                              //speedTV.setText(downSpeed+&quot; mbps&quot;);
                              // speedTV.setText(finalRate);
                              progress_circular_id.setProgress(status);
                              textview_progress_status_id.setText(String.valueOf(status) + &quot;%&quot;);
      
                              if (status == 100) {
                                  dialog.dismiss();
                              }
                          }
                      });
      
      
                  }
      
                  output.flush();
                  output.close();
                  input.close();
                  return &quot;Downloaded at: &quot; + directory.getPath() + fileName;
              } catch (IOException e) {
                  Log.e(&quot;Abhan&quot;, &quot;Error: &quot; + e.getLocalizedMessage());
                  runOnUiThread(new Runnable() {
                      public void run() {
                          hideProgressDialog();
      
                      }
                  });
              }
              hideProgressDialog();
              return &quot;Downloading Error&quot;;
          }
  </code></pre>
  <p>i am trying to download file using image URL to my android device sd card
  /storage/emulated/0/Movies/RoveDashCam/Photos/2022_0103_124619_001.JPG
  but when i a run code i am getting below exception
  java.io.FileNotFoundException: /storage/emulated/0/Movies/RoveDashCam/Photos/2022_0103_124619_001.JPG: open failed: EPERM (Operation not permitted)r</p>
  <p>i am trying to give permission dynamically  but it show permission already granted then also i am unable to download file</p>
  <p>please help me what mistake i am doing .</p>