Storing a bitmap for several activities?

I'm looking for a way to store some bitmap images that can be accessed in a few steps, without having to reboot from the Internet.

I don’t want to just transfer them from Activity to Activity, putting them in Intent , but rather, there is one place where I can access them without transferring them.

I was looking for caching to help solve this problem, but if it is a solution, I am a bit unclear how to make the cache accessible in a few steps.

Any suggestions or alternative solutions are welcome.

+4
source share
3 answers

You can use LruCache , a library such as Volley , or implement the same functionality yourself. I think a volley library would be perfect for you.

To access it from anywhere in the application, you must either save it in a special application object or in a static variable. Please note that only the cache link will be stored there. The cache size in both cases listed above is configurable.

+2
source

What does the cache accesible in multiple activities mean? Just download it from the Internet, save it to the SD card (chache it), and then download it from the SD card from the number of active actions as much as you want.

Below is an example of how you can store data on Android.

You can use the Picasso downloader for this task.

0
source

You can make a static array or a bitmap map and access it wherever you want. If there are many images, you can also create queues and store only the most recent ones used there.

-1
source

Source: https://habr.com/ru/post/1488174/


All Articles