UIL can cache image on SD card (enable caching in DisplayImageOptions). You can define your own folder for cache (in ImageLoaderConfiguration).
If you want to display image from SD card using UIL you should pass URL like:
file:///mnt/sdcard/MyFolder/my_image.png
I.e. use file://
prefix.
UPD:
If you want save image on SD card:
String imageUrl = "...";
File fileForImage = new File("your_path_to_save_image");
InputStream sourceStream;
File cachedImage = ImageLoader.getInstance().getDiscCache().get(imageUrl);
if (cachedImage != null && cachedImage.exists()) { // if image was cached by UIL
sourceStream = new FileInputStream(cachedImage);
} else { // otherwise - download image
ImageDownloader downloader = new BaseImageDownloader(context);
sourceStream = downloader.getStream(imageUrl, null);
}
if (sourceStream != null) {
try {
OutputStream targetStream = new FileOutputStream(fileForImage);
try {
IoUtils.copyStream(sourceStream, targetStream, null);
} finally {
targetStream.close();
}
} finally {
sourceStream.close();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…