caching images that are retrieved

Posted by Rahul Varma on Stack Overflow See other posts from Stack Overflow or by Rahul Varma
Published on 2010-04-27T04:46:49Z Indexed on 2010/04/27 4:53 UTC
Read the original article Hit count: 255

Filed under:
|

Hi, I am retrieving a list of images and text from a web service. The images are getting displayed in the list view. But the problem is, when i scroll down the list the entire images are getting loaded once again. When i scroll twice or thrice there is a OutofMemory occuring... Can anyone tell me how to cache the images and also to avoid the loading of the images that are already loaded when i scroll down. I have tried to increase inSampleSize but it didnt work... Here's the code....

public static Bitmap loadImageFromUrl(String url) {
      InputStream inputStream;
      Bitmap b;
  try {


   inputStream = (InputStream) new URL(url).getContent();
   BitmapFactory.Options bpo= new BitmapFactory.Options();
   b=BitmapFactory.decodeStream(inputStream, null,bpo );
b.recycle();
   bpo.inSampleSize=2;




 return b;
  } catch (IOException e) {
          throw new RuntimeException(e);
      }

// return null; }

© Stack Overflow or respective owner

Related posts about android

Related posts about bitmap