I'm receiving a null value from my hashmap. This is the hashmap creation:
private HashMap<String,Bitmap> thumbs = new HashMap<String,Bitmap>();
/* adding a single value to the hashmap */
Then I proceed to retreiving the value from the hashmap, like so:
public Bitmap getImageByFileName(String fileName) {
Bitmap fish = null;
Iterator it = thumbs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
fish = (Bitmap)thumbs.get(fileName);
it.remove();
}
Log.i("shnitzel", " bitmap is " + fish);
fish = (Bitmap)thumbs.get(fileName);
Log.i("shnitzel", " final bitmap is " + fish);
return fish;
}
The log file:
08-05 22:18:28.170: I/shnitzel(477): bitmap is android.graphics.Bitmap@40650138
08-05 22:18:28.170: I/shnitzel(477): final bitmap is null
As you can see, I use the exact same command inside and outside the 'while' loop, but for some reason it works inside it, but not outside. Why does this happen?