title: save file to internal memory in android?
body: <p>I am downloading a file from server with help of a URL provided through web service.
  I am successful for every version of devices but getting exception in OS 4.1 devices.
   I am using below code:</p>
  
  <pre><code>public static Boolean DownloadFile(String fileURL, File directory) {
                  try {
  
                          FileOutputStream f = new FileOutputStream(directory);
                          URL u = new URL(fileURL);
                          HttpURLConnection c = (HttpURLConnection) u.openConnection();
                          c.setRequestMethod("GET");
                          c.setDoOutput(true);
                          c.connect();
  
                          InputStream in = c.getInputStream();
  
                          byte[] buffer = new byte[1024];
                          int len1 = 0;
                          while ((len1 = in.read(buffer)) &gt; 0) {
                                  f.write(buffer, 0, len1);
                          }
                          f.close();
                          return true;
                  } catch (Exception e) {
                          e.printStackTrace();
                          return false;
                  }
          }
  </code></pre>
  
  <p>I am getting java.io.FileNotFoundException at line <strong>c.getInputStream();</strong>
  please suggestion me to solve this problem.</p>
  
  <p>I am planning to use the internal memory but as user cant access the internal memory.</p>