0

I'm currently building an android application, and I'm making some HttpRequests to grab images from an API. Right now I'm just storing them in an object container, and then storing them in ArrayLists, but I want to store it into a temporary cache for the application so that when I quit out of that particular activity and go back into the launcher activity, when I go back into that activity, I won't have to make another httprequest for the image.

However, I don't know where to start, what to read up on, or anything regarding temporary storage. I've only used SharedPreferences, and passing extras along intents. Can anyone point me to any good places to get started with, either documentation or sample code?

edit: I forgot to mention that I'd like the data to be deleted when I quit out of the application. I'm not too sure what caching even means, so I don't know if this happens by default when people talk about "caching"

tshepang
  • 12,111
  • 21
  • 91
  • 136
confused
  • 123
  • 2
  • 7

2 Answers2

1

You could refer to Android - How do I do a lazy load of images in ListView.

There are a cache example in Fedor's LazyList.zip from the answers.

Community
  • 1
  • 1
Jett Hsieh
  • 3,159
  • 27
  • 33
0

The Activity class has some great information on cache directories and the Lifecycle. If your cache is more than a couple megabytes you should consider using external storage.

Dan S
  • 9,139
  • 3
  • 37
  • 48