Code example for SoftReference

                protected boolean removeEldestEntry( 
                        LinkedHashMap.Entry<URL, ExpiringBitmap> eldest) {
                    // Moves the last used item in the hard cache to the soft 
                    // cache. 
                    if (size() > mMaxCapacity) {
                                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();
Contextual code suggestions in your IDE  Get Codota for Java