Code example for SoftReference

0
                protected boolean removeEldestEntry( 
                        LinkedHashMap.Entry<URL, ExpiringBitmap> eldest) {
                    // Moves the last used item in the hard cache to the soft 
                    // cache. 
                    if (size() > mMaxCapacity) {
                        mSoftCache.put(eldest.getKey(),
                                new SoftReference<ExpiringBitmap>(eldest.getValue()));
                        return true; 
                    } else 
                        return false; 
                } 
            }; 
        } 
 
        public Set<URL> clear() {
            Set<URL> clearedUrls = new HashSet<URL>();
 
            synchronized (mHardCache) {
 
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.DATE, -1);