Code example for HashMap

Methods: containsKey, get

0
    } 
    return null; 
  } 
 
  public void DisplayImage(int uid, Activity activity, ImageView imageView) {
    if (cache.containsKey(uid))
      imageView.setImageBitmap(cache.get(uid));
    else { 
      queuePhoto(uid, activity, imageView);
      imageView.setImageResource(stub_id);
    } 
  } 
 
  private Bitmap getBitmap(int uid) {
    // I identify images by hashcode. Not a perfect solution, good for the 
    // demo. 
    String filename = String.valueOf(uid);
    File f = new File(cacheDir, filename);
 
    // from SD cache 
    Bitmap b = decodeFile(f);