1

I'm using universal image loader version 1.5.9 , this is my code, I want to cache the images to not download every time I reload the activity , I don't close the application but it downloads the image every time :

    ImageLoader imageLoader = ImageLoader.getInstance();
File cacheDir = StorageUtils.getCacheDirectory(context);
config= new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .build();
        imageLoader.init(config);

    imageLoader.displayImage(img, viewHolder.img);

What is the problem ? why does it download the image every time ?

Harsh Sharma
  • 97
  • 1
  • 10
j jones
  • 477
  • 7
  • 24

2 Answers2

0

Use Glide, as it is the fastest way to access image launched in android 5 find the example codes below: http://www.androidhive.info/2016/04/android-glide-image-library-building-image-gallery-app/

0

Read the documentation. Point 1 in Useful Info clearly states that caching is NOT enabled by default. You need to set caching enabled in your config for it to actually cache anything.

       .cacheInMemory(true)
       .cacheOnDisk(true)
Qw4z1
  • 3,041
  • 1
  • 24
  • 36