I'm trying to cache images for offline use in android, as suggested on this answer: https://stackoverflow.com/a/40544554/1718174
However the problem is, I'd like to use the offline image on another subsequent activity. For example:
- While online my first screen loads and shows a list of products with photos
- Then I go offline. If I click on the product for a better look at the photo, the image does not load while offline (even though the image is already cached for the first activity).
If I use the example code on the first link, but on the second activity, it only shows the image when the user goes online again. Any ideas on how to achieve this? Maybe get the bytes or a bitmap from the "Glide" call?
The only working alternative I've found was to also store the image as base64, as suggested here: https://stackoverflow.com/a/22651605/1718174
But that doesn't seem to be very optimal. I have to store the same thing twice!