Saeed Masoumi Saeed Masoumi - 1 month ago 23
Android Question

How save image in Android Universal Image Loader?

In

Lazy-List
i use this code and my image store in a folder named
LazyList


ImageLoader imageLoader=new ImageLoader(context);
imageLoader.DisplayImage(url, imageView);


But in
Universal-Image-Loader
i use this

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.build();
ImageLoader.getInstance().init(config);
img = (ImageView) this.findViewById(R.id.test_id);
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(URL.RECIPE_IMG_URL,img);


but each time it use internet to get image and didn't store my image in any folder i aslo add
.diskCache(new UnlimitedDiscCache(new File("myFolder")))
to
config

but nothing store in
myFolder
.Any ideas?

Answer

I found my answer . By default caching is disable i should add DisplayImageOptions to ImageLoaderConfiguration

And here is code

   DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .build();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
                .defaultDisplayImageOptions(defaultOptions)
                .build();