so i have a listview with images from some urls, i tryed to save the pictures after loading in a arrayList of bitmaps but in the end only 2-3 pictuers showed in the list on my device (the emulator shows all pictures), so i tried to cache the pictures after downloading and i use: `
for (int i = 0; i < url.length; i++){
URL urlAdress = new URL(url[i]);
HttpURLConnection conn = (HttpURLConnection) urlAdress
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
Bitmap bmImg = BitmapFactory.decodeStream(is);
// picList.add(bmImg);
File cacheDir = context.getCacheDir();
File f = new File(cacheDir, "000" + (i + 1));
FileOutputStream out = null;
try {
out = new FileOutputStream(f);
bmImg.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null)
out.close();
} catch (Exception ex) {
}
}
}
` to save the pics in cache, and then i use this to load the pictures from cache in the adapter :
File cacheDir = context.getCacheDir();
File f = new File(cacheDir, "000" + position);
Drawable d = Drawable.createFromPath(f.getAbsolutePath());
holder.icon.setImageDrawable(d);
but i still get 3-4 pictures from 9, is this a memory issue ? (all the pics together have 300 kb)