将位图(资源)添加到缓存

要将资源添加到缓存,你必须提供密钥和资源。首先确保该值不在缓存中

public void addResourceToMemoryCache(String key, Bitmap resource) {
    if (memoryCache.get(key) == null)
        memoryCache.put(key, resource);
}