Skip to content Skip to sidebar Skip to footer

Android Universal Image Loader Clear Cache

i use universal image loader to load image from url this is adapter public class BinderDataImg extends BaseAdapter { static final String KEY_IMG = 'img'; LayoutInflater inflater;

Solution 1:

You can use DiskCacheUtils and MemoryCacheUtils to remove specific image by image url

DiskCacheUtils.removeFromCache(imageUrl, ImageLoader.getInstance().getDiskCache());    
MemoryCacheUtils.removeFromCache(imageUrl, ImageLoader.getInstance().getMemoryCache());

or to completely clean cache

ImageLoader.getInstance().clearMemoryCache()
ImageLoader.getInstance().clearDiskCache()

To clear cache when activity created you can call this methods after you initialized your ImageLoader

To clear cache on leaving the activity you can call methods in onDestroy () , but i should mind that system can kill your activity without calling this method.

Solution 2:

ImageLoader class has two methods to clear caches: clearMemoryCache and clearDiscCache. Call them in activity onDestroy method will do what you are looking for.

Post a Comment for "Android Universal Image Loader Clear Cache"