Code example for WeakHashMap

Methods: containsKey, get, put

0
    { 
        if (key == null)
        { 
            return null; 
        } 
        if (mCache.containsKey(key))
        { 
            SoftReference<Bitmap> reference = mCache.get(key);
            Bitmap bitmap = reference.get();
            if (bitmap != null)
            { 
                return bitmap;
            } 
            return decodeFile(key);
        } 
        // the key does not exists so it could be that the 
        // file is not downloaded or decoded yet... 
        return decodeFile(key);
 
    } 
 
    private  Bitmap decodeFile(String key)
    { 
        Bitmap bitmap = BitmapFactory.decodeFile(storage + key);
        mCache.put(key, new SoftReference<Bitmap>(bitmap));
        return bitmap;
    } 
 
 
    public  Drawable getImageDrawable(String file)