Universal Image Loader reuse images in android - android

Using Universal Image Loader, is it possible to directly save images to disk and reuse those images between different runs of the application?
I know imageLoader.displayImage(imageURI, itemHolder.image, options); gets images from the cache the second time, but if you exit the app the cache is removed.
I want the display image method to save the image to a permanent location and use that location every time the app calls that method.
Is this possible using Universal Image Loader or do I need to find another way?

you need to download images to certain folder at first start up and after that you can load images using same method and you need to pass file location instead of url like:
imageLoader.displayImage("file:///sdcard/test.png", itemHolder.image, options);
Hope this will help you

Related

Fetch Image from server by using url with Universal Image Loader

I am successfully fetching and caching image from server url by using Universal Image Loader. My DisplayImageOptions are given below.
new DisplayImageOptions.Builder().cacheInMemory(true)
.showImageOnLoading(R.drawable.home_back_img)
.showImageOnFail(R.drawable.home_back_img)
.bitmapConfig(Bitmap.Config.ALPHA_8)
.showImageForEmptyUri(R.drawable.home_back_img)
.build();
My problem is, when I updates image in server(with same file name), the image is not updated in application, its just using the cached file itself. Is there is any solution for this? Yes we can avoid caching, but then it might take some time to load the image every time, rather than avoid caching it would be nice if any solution exists. Help will be appreciated!
You must use different name to get the updated photo. Because , the image already stored in your local cache by the same name. So, It will never call to network to download the image .
Or , Clear your application cache , then you will get the updated image.

Can Universal Image Loader use different DiskCache for images?

I'm using Universal Image Loader for image loading, In the document I can't find a way to set different DiskCache for image display, the DiskCache directory is set by ImageLoader.getInstance().init(), which is global.
But I want to store some images in a separate DiskCache because I don't want it to be removed when LruDiskCache is full or cleared manually, I there anyway to do this?
I am afraid UIL can't store specific image files intently. If I guess right, these images that you want to store in separate directory are used frequently. But, maybe you don't understand the mechanism of LruDiskCache which means "least recently used disk cache". Which means files used frequently would at the header of the queue all the time. So, if you use LruDiskCache, these images used frequently will be always stored in the disk and not be deleted or cleared. So, your requirement has been fulfilled when you use LruDiskCache.

Android Image fetching library

Hi i wanted to know is their any library in which we pass the URL and the image-view and it checks whether the images is present on device if not, then fetch image from URL and store to device and bind with the view passed. I tried writing the code but once the view is loaded and image is not fetched the images is never fetched in future unless i uninstall the app , i also tried universal image loader library and asynchronous image loader
Picasso is doing all things what you want.
It loads from internet and cache
It loads from cache
It loads from Local File
Read More Here And Here
Try volley library. you have a NetworkImageView I guess. Which fits your need.

Universal Image Loader enable/disable disc cache for each image

In my android app, I am using Universal Image Loader to display images.
I specified in the option to caching images on Disc. But sometimes there are images that I do not want to cache on the disc. Is there a way to specify if it should cache on disc or not for each time I download an image and not only in the initialization?
Thanks
I just created 2 options one with caching and one without and used each one accordingly.
Will leave it here in case.

Loading images from the server is very slow

I am trying to load images from the server and want to know how can i convert the images into the thumbnails so that they get uploaded fast and how can i get the larger images from the thumbnails fast . I have tried many things.
Thanks in advance
At the server you need to keep 2 copies of an image. First is the thumbnail and the other one is the image.
First you need to download the thumbnail asynchronously. And if the user wishes to see it then download the original image asynchronously. While downloading original image you can show the scaled thumbnail image as the placeholder image. So when the downloading is completed show the downloaded image.
Make sure to download the images asynchronously otherwise you will block the main thread and UI will get stuck.
This is how google images work.
In iOS there is a very nice API SWPhotoBrowser which handles the downloading and caching of photos from the web seamlessly. I am sure there must be some API for Android as well.
If you need any help I can help with the code as well.
For Android you can use ImageLoader to download and display image - it can use cache and save memory while loading scaled images.

Categories

Resources