
Universal Image Loader is a popular graphic library in Android Development, since it maintains lots of useful functions, which are complicated for programmers to manually implement.
Universal Image Loader has a feature, it can save cache of pictures that are downloaded from the Internet. But if there are lots of cache in your phone, that will be a tremendous waste of your disk space.
According to the source code of Universal Image Loader, it will give every images a hash before it cache them on the disk. The hash is corresponding with the url of the picture.
Before we can use this library, we need to initialize some configurations such as the cache path, the maximum total size of cached files etc. But if we just want to delete those caches, we just need to initialize its storage path:
ImageLoader.getInstance()
.init(new ImageLoaderConfiguration.Builder(this)
.diskCache(new UnlimitedDiskCache(StorageUtils
.getOwnCacheDirectory(this, "ShiyiquanImgs/Cache")))
.build());
By using this code, we can initialize the ImageLoader on current context with an attribute, which is the storage path.
Thus, we can simply use the method called ‘clearDiskCache()’ in ImageLoader class.
ImageLoader.getInstance().clearDiskCache();




近期评论