title: Always FileNotFoundException Permission Denied in android
body: <p>Why do i always get this error FileNotFoundException Permission Denied? The code is going smooth but when i click a file to download, it wont be downloaded. Please help me. im new to this </p>
  
  <p>Here is my logcat</p>
  
  <pre><code>03-28 09:19:34.695: E/log_tag(17921): eer java.io.FileNotFoundException: /mnt/sdcard/Excel.xlsx (Permission denied)
  </code></pre>
  
  <p>In my manifest</p>
  
  <pre><code>   &lt;uses-sdk android:minSdkVersion="11" 
            android:targetSdkVersion="15"
            android:maxSdkVersion="16" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>this is my download function </p>
  
  <pre><code>//Download
      public void startDownload(final int position) {     
  
          Runnable runnable = new Runnable() {
              int Status = 0;
  
              public void run() {
  
                  String urlDownload = MyArrList.get(position).get("FileUrl").toString();
                  int count = 0;
                  try {
                        Log.d("", urlDownload);
                      URL url = new URL(urlDownload);
                      URLConnection conexion = url.openConnection();
                      conexion.connect();
  
                      int lenghtOfFile = conexion.getContentLength();
                      Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
  
                      InputStream input = new BufferedInputStream(url.openStream());
  
                      // Get File Name from URL
                      String fileName = urlDownload.substring(urlDownload.lastIndexOf('/')+1, urlDownload.length() );
                  //Environment.getExternalStorageDirectory().getPath()
                      Log.d("", fileName);
                      OutputStream output = new FileOutputStream(Environment.getExternalStorageDirectory().getPath()+"/"+fileName);
  
                      byte data[] = new byte[1024];
                      long total = 0;
  
                          while ((count = input.read(data)) != -1) {
                              total += count;
                              Status = (int)((total*100)/lenghtOfFile);
                              output.write(data, 0, count);
  
                              // Update ProgressBar
                              handler.post(new Runnable() {
                                  public void run() {
                                      updateStatus(position,Status);  
                                  }
                              });
  
                          }
  
                          output.flush();
                          output.close();
                          input.close(); 
  
                      } catch (Exception e) {
                          e.printStackTrace();
                          Log.e("log_tag", "eer "+e.toString()); 
  
                      }
  
  
              }
          };
          new Thread(runnable).start();
      }
  </code></pre>
  
  <p>Well, im trying to download an excel file from the server. Each file is displayed as list on which when i click it, it will be downloaded. But Everytime i clicked the file. it outputs the error on the log.cat i gave you</p>