title: How can I download a video file to SD card?
body: <p>I have a video file(.MP4 format) and I want to allow the user to be able to download the video to their SD card.I currently use this code but its not working..</p>
  
  <pre><code>String PATHSdcard = "/sdcard/Video/";  
  
   public void DownloadFromUrl(String VideoURL, String fileName)         
  
  
  try { URL url = new URL("https://javmed-prod.s3.amazonaws.com/666034cbe81045f2a2da50e5205e376b.mp4");
               File file = new File(fileName);
  
               long sTime = System.currentTimeMillis();
               URLConnection URLcon = url.openConnection();
  
               InputStream is = URLcon.getInputStream();
               BufferedInputStream bis = new BufferedInputStream(is);
  
               ByteArrayBuffer baf = new ByteArrayBuffer(50);
               int current = 0;
               while ((current = bis.read()) != -1) {
                       baf.append((byte) current);
               }
  
               FileOutputStream fos = new FileOutputStream(PATHSdcard+file);
               fos.write(baf.toByteArray());
               fos.close();
  
       } catch (IOException e) {
               Log.d("ERROR.......",e+"");
       }
  </code></pre>
  
  <p><strong>thanks for any help!</strong></p>