Android apps now account for a larger memory than one, and the quality of Android programs needs to be improved.
Here is a brief description of the network image cache, my side of the simple talk about ideas
1: Network pictures, undoubtedly need to download pictures, we do not need to download each time.
Maintain a table, the table contains the URL corresponding to the stored file name
The implementation method is to get the URL to download, take this URL to the database match, if there is this picture, it does not need to re-download, directly through the database, to get the location of the picture, and then from the local loading the picture is OK. When you don't have this picture, download it and save the database.
Benefits: The benefits of doing so obviously, downloaded pictures do not need to re-download, but also save the local space, download many of the same picture local is not good.
2: Image resources memory processing, a picture needs to be displayed in many places, such as their avatar, need to show in many places, do not need every place to load this picture, this will waste a lot of resources.
Implementation method, in memory to maintain a bitmap map,key put Url,value put this bitmap we get a URL, first see if there is this image in memory, there is directly from the use.
Benefits: Bitmap is very memory, reuse it can save a lot of memory, and then load the picture from the local also need to consume resources, each picture as long as the load once, this is not much better.
To achieve these two points, the image of the efficiency of this piece can be seen a lot more, oom god horse I will not say, write this hope everyone to the program optimization will have some help, as for this tool class have time to write it, online also have a lot of, write this blog also want to see can get a few C coins, recently very busy, Also have no time to write a blog, roughly write a gangster C-money, for everyone should also be a bit of help
Cache of Android Images-save memory and improve program efficiency