title: Android Java.io.FileNotFoundException when trying to download and save a video
body: <p>I'm trying to develop an app which provides many movies and you can play it or download the movie.</p>
  
  <p>That app works fine in my <strong>rooted</strong> Galaxy S4 (Kitkat API:19),
  but when I install it on another device and try to download the movie it gives my the exception <code>Java.io.FileNotFoundException</code>, I don't know what's the problem</p>
  
  <p>That's my code</p>
  
  <pre><code>package nmc.net.blue.bluenet_nmc;
  
  import android.content.Context;
  import android.os.AsyncTask;
  import android.os.Environment;
  import android.util.Log;
  import android.widget.Toast;
  
  import java.io.BufferedInputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.net.URL;
  import java.net.URLConnection;
  
  /**
   * Created by ElHoni on 5/3/2016.
   */
  public class DownloadFileAsync extends AsyncTask&lt;String, String, String&gt; {
  
  
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
  
      @Override
      protected String doInBackground(String... aurl) {
          int count;
  
          try {
              URL url = new URL(aurl[0]);
              URLConnection conexion = url.openConnection();
              conexion.connect();
  
              File folder = new File(Environment.getExternalStorageDirectory() +
                      File.separator + "BlueNet");
  
              if (!folder.exists()) {
                  folder.mkdirs();
              }
  
  
              String outputPath=folder.getPath()+"/"+aurl[1];
  
              BufferedInputStream input = new BufferedInputStream(url.openStream());
              FileOutputStream output = new FileOutputStream(outputPath);
  
              byte data[] = new byte[1024];
  
              long total = 0;
  
              while ((count = input.read(data, 0, 1024)) != -1) {
                  output.write(data, 0, count);
  
              }
  
              output.flush();
              output.close();
              input.close();
          } catch (Exception e) {
              String err = e.toString();
  
          }
          return null;
  
      }
      protected void onProgressUpdate(String... progress) {
          Log.d("ANDRO_ASYNC",progress[0]);
      }
  
      @Override
      protected void onPostExecute(String unused) {
  
          //Toast.makeText(full_screen_video.this, "", 5);
  
      }
  
  }
  </code></pre>
  
  <p>and by the way
  i put this permissions in manufests</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>any help please</p>