if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File rootSD = Environment.getExternalStorageDirectory();
file = new File(rootSD, “pic”);
if (!file.exists()) {
file.mkdirs();
}
}
try {
diskCache = new LruDiskCache(file, new Md5FileNameGenerator(), 50 * 1024 * 1024);
} catch (IOException e) {
e.printStackTrace();
}
BitmapDisplayer displayer = new CircleBitmapDisplayer(10);
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheOnDisk(true)
.cacheInMemory(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.displayer(displayer)
.showImageOnFail(R.mipmap.ic_launcher)
.showImageOnLoading(R.mipmap.ic_launcher)
.showImageForEmptyUri(R.mipmap.ic_launcher)
.build();
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
.diskCache(diskCache)
.memoryCache(new LruMemoryCache(12 * 1024 * 1024))
.threadPoolSize(3)
.defaultDisplayImageOptions(options)
.build();
ImageLoader.getInstance().init(configuration);
}