將點陣圖(資源)新增到快取

要將資源新增到快取,你必須提供金鑰和資源。首先確保該值不在快取中

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