title: HttpURLConnection is not saving the file
body: <p>I am trying to download images from flickr api, as:</p>
  
  <pre><code>   //in main:
      new GetFlickr().execute(Lat, Long);
  
  
     //  Subclass to download photos from flickr
        public class GetFlickr  extends AsyncTask&lt;Double, Double, String&gt; {
          private String lat = "23.87";
          private String lang = "81.55";
          private String flickr_api = "https://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=";
          private String flickr_key = "Flickr_API_KEY";
          private String flickr_opt = "&amp;format=rest&amp;accuracy=11&amp;content_type=1&amp;privacy_filter=1&amp;geo_context=2";
          private String urls = flickr_api + flickr_key + "&amp;lat=" + lat + "&amp;long=" + lang + flickr_opt;
          private ProgressBar pBar;
  
          @Override
          protected void onPreExecute(){
            super.onPreExecute();
            pBar = new ProgressBar(getApplication());
            Toast.makeText(getApplicationContext(), urls, Toast.LENGTH_LONG).show();
            System.out.println(urls);
  
          }
  
          @Override
          protected String doInBackground(Double... doubles) {
            try{
              URL url = new URL(urls);
              HttpURLConnection connection = (HttpURLConnection)  url.openConnection();
              connection.connect();
              File file = new File(getApplicationContext().getFilesDir(),"flickr.xml");
              FileOutputStream fOut = new FileOutputStream(file);
              InputStream fInp = connection.getInputStream();
              int totalSize = connection.getContentLength();
  
              int downloadedSize = 0;
  
              byte[] buffer = new byte[1024];
              int bufferLength = 0; //used to store a temporary size of the buffer
  
              //now, read through the input buffer and write the contents to the file
              while ((bufferLength = fInp.read(buffer)) &gt; 0) {
                fOut.write(buffer, 0, bufferLength);
                //Toast.makeText(getApplicationContext(), Double.toString(bufferLength), Toast.LENGTH_LONG).show();
                downloadedSize += bufferLength;
              }
              fOut.close();
            } catch (MalformedURLException e){
              e.printStackTrace();
            } catch (IOException e){
              e.printStackTrace();
            }
            return null;
          }
  
          protected void onProgressUpdate(Integer... values) {
            pBar.setProgress(values[0]);
          }
  
          @Override
          protected void onPostExecute(String s) {
            super.onPostExecute(s);
            pBar.setVisibility(View.GONE);
          }
        }
  </code></pre>
  
  <p>While the <code>urls</code> created is correct (I can copy paste it in my browser, and getting the xml files back) the file is not saved anywhere, so that I can parse it.</p>
  
  <p>Also, I need to pass, two double, <code>Lat</code> and <code>Lang</code>, so probably my function argument is also wrong. Being very new to java, I don't know how to define <code>params</code>. </p>
  
  <p>Kindly tell me what i am doing wrong here.</p>
  
  <p><strong>Update</strong> I am expecting to get a file like</p>
  
  <pre><code>&lt;rsp stat="ok"&gt;
  &lt;photos page="1" pages="1413" perpage="250" total="353095"&gt;
  &lt;photo id="49344451012" owner="111497945@N04" secret="7d073516fb" server="65535" farm="66" title="Etretat" ispublic="1" isfriend="0" isfamily="0"/&gt;
  &lt;photo id="49343777058" owner="186211180@N06" secret="b937a40e99" server="65535" farm="66" title="vinhomes-smart-city-vuon-nhat-1" ispublic="1" isfriend="0" isfamily="0"/&gt;
  &lt;photo id="49344446262" owner="57849799@N04" secret="a9e0d0a1ac" server="65535" farm="66" title="Solitario" ispublic="1" isfriend="0" isfamily="0"/&gt;
  &lt;photo id="49344229736" owner="58472155@N05" secret="d4ff74d968" server="65535" farm="66" title="IMG_0565" ispublic="1" isfriend="0" isfamily="0"/&gt;
  &lt;photo id="49343774068" owner="58472155@N05" secret="fac23b927c" server="65535" farm="66" title="IMG_0572" ispublic="1" isfriend="0" isfamily="0"/&gt;
  &lt;photo id="49343773223" owner="50072010@N04" secret="25f12643e6" server="65535" farm="66" title="Aarti Ritual of the Sacred Ganges - Haridwar, India" ispublic="1" isfriend="0" isfamily="0"/&gt;
  </code></pre>
  
  <p>from which I have to extract <code>farm</code>, <code>secret</code> etc</p>