title: Best method to download image from url in Android
body: <p>I'm using below method to download single image from url</p>
  
  <pre><code>public static Bitmap getBitmap(String url) {
      try {
          InputStream is = (InputStream) new URL(url).getContent();
          Bitmap d = BitmapFactory.decodeStream(is);
          is.close();
          return d;
      } catch (Exception e) {
          return null;
      }
  }
  </code></pre>
  
  <p>Sometimes I get an outofmemory exception.</p>
  
  <p>I am unable to catch outofmemory exception. The app will close. How to prevent this? </p>
  
  <p>Is there a better method for downloading images that is also faster?</p>