Android: image cache sharing

I am developing an Android application and I can’t understand how best to implement a two-level image cache that can be used for several actions in one application.

Example:

The application has 3 actions (A, B and C) and, for the sake of argument, allows us to say that A calls B and B calls C and C A. Each action displays an image downloaded from the Internet, and I use asynctask to download and display images with each action is simple enough. Now I would like to add an image cache to avoid multiple downloads of the same image.

Currently, each action launches a new instance of simple asynthesis, which loads the image and updates the view accordingly. Obviously, it’s easy enough to update the basic synthesis to check the image cache before starting to download and update the cache after the download is complete, but I was fixated on how / where to create and initialize the cache. Any thoughts would be appreciated.

+3
source share
1 answer

You can add this to your application manifest:

application android: name = "MyApplication" (...)

"MyApplication" . . , . , "", , . - ( ):

ArrayList myStrings = (( ) this.getApplication()) getRandomStrings();.

, .:)

: "MyApplication" :

MyApplication

+2

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


All Articles