简体   繁体   English

如何将下载的图像存储在缓存中

[英]How to store downloaded images in cache

I'm working on a Syllabus application for my project in Android which shows a list of subjects in a RecyclerView . 我正在为我的Android项目开发教学大纲应用程序,该程序在RecyclerView显示了主题列表。 When clicked on a subject, it downloads the image from its URL and displays it in the ImageView . 单击主题时,它将从其URL下载图像并将其显示在ImageView I need a code which stores the Image in cache once it is downloaded, so the user doesn't need to download the image from the URL again and again. 我需要一个将图片下载后存储在缓存中的代码,因此用户无需一次又一次从URL下载图片。

For downloading images, you can use Glide library. 要下载图像,可以使用Glide库。 This library lets you download the image efficiently and cache them also so you don't have to manually do it. 该库使您可以有效地下载图像并缓存它们,因此您不必手动进行操作。

如果您有很多图像要加载到您的应用程序中,我会提供使用外部存储而不是缓存,因为如果您的应用程序缓存已满,android会删除所有应用程序缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM