title: How to download images and store in sdcard in android?
body: <p>I am prepared code for download images from server and store in sdcard.For that i have prepared code,</p>
  
  <pre><code> URL url;
   try {
       url = new URL("http://myserver_path/applikaza/appstore/apks/ScrResoluton/scrresolution.jpg");
       input = url.openStream();
       String storagePath = Environment.getExternalStorageDirectory().toString();
       String basepath = storagePath + "/Guayama/" + folderName;
       output = new FileOutputStream(basepath + "/home.png");
       byte[] buffer = new byte[5000];
  
       int bytesRead = 0;
       while ((bytesRead = input.read(buffer, 0, buffer.length)) &gt;= 0) {
           output.write(buffer, 0, bytesRead);
       }
  
   } catch (MalformedURLException e) { // TODO Auto-generated catch block
       e.printStackTrace();
   } finally {
       output.close();
       input.close();
   }   
  </code></pre>
  
  <p>but got NullPointerException at  <code>output.close()</code>.I think done mistake some where .please help me. </p>