0

I am developing an Android application where I need to show some images in a recyclerview. I want to download the images at once and probably save it in cache or internal storage of the android and then show the images from the internal storage if there are images in storage and if not then load and download from server.

And I don't want these images to appear in the user's Gallery App.

I just want to know the architecture , not the code about how to do it.

Is there any difference between the cache memory and internal storage? And do I need the permission to save the images in cache?

EDIT:

My question is different from the one suggested by @Dima, in that question he is not caching the images or save it in internal storage, i reckon.

Aman Verma
  • 3,155
  • 7
  • 30
  • 60
  • Possible duplicate of [Caching images and displaying](https://stackoverflow.com/questions/16789676/caching-images-and-displaying) – Dima Kozhevin Sep 23 '17 at 16:52

1 Answers1

0

Glide is a great library for showing image asynchronously.

Glide's disk cache strategies:

Glide 3.x & 4.x: DiskCacheStrategy.NONE caches nothing, as discussed

Glide 4.x: DiskCacheStrategy.DATA, Glide 3.x: DiskCacheStrategy.SOURCE caches only the original full-resolution image. In our example above that would be the 1000x1000 pixel one

Glide 4.x: DiskCacheStrategy.RESOURCE Glide 3.x: DiskCacheStrategy.RESULT caches only the final image, after reducing the resolution (and possibly transformations) (default behavior of Glide 3.x)

Glide 4.x only: DiskCacheStrategy.AUTOMATIC intelligently chooses a cache strategy based on the resource (default behavior of Glide 4.x)

Glide 3.x & 4.x: DiskCacheStrategy.ALL caches all versions of the image As a last example, if you've an image which you know you'll manipulate often and make a bunch of different versions of it, it makes sense to only cache the original resolution. Thus, we'd tell Glide to only keep the original:

example:

Glide 4.x

GlideApp  
    .with(context)
      .load(eatFoodyImages[2])
      .diskCacheStrategy(DiskCacheStrategy.DATA)
      .into(imageView3);

Glide 3.x

Glide  
    .with( context )
    .load( eatFoodyImages[2] )
    .diskCacheStrategy( DiskCacheStrategy.SOURCE )
    .into( imageViewFile );

and the cached will be in data folder of your app so won't show up in user gallery.

SemyColon.Me
  • 378
  • 3
  • 18