Android image Cache Management

Source: Internet
Author: User
Link: http://keegan-lee.diandian.com/post/2012-12-06/40047548955

If you need to obtain the same image from the network every time you load it, the cost is too high. Therefore, you only need to obtain the same image from the network once, and then cache it locally. Then, load the same image from the cache. Reading images from the memory cache is the fastest, but because the memory capacity is limited, it is best to add the File Cache. The file cache space is not infinitely large. The larger the capacity, the lower the reading efficiency. Therefore, you can set a limited size such as 10 MB or a limited storage time such as one day.

Therefore, the image loading process should be:

1. obtain from the memory cache first. If the result is obtained, return. If the result is not obtained, proceed to the next step;

2. obtain from the File Cache. If the result is obtained, it is returned and updated to the memory cache. If the result is not obtained, proceed to the next step;

3. Download images from the network and update them to the memory cache and file cache.

 

Next we will look at the memory cache class: imagememorycache

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 public

class

ImageMemoryCache {

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.