简体   繁体   中英

Android WebView: Is there a way to refresh only selected svg images in cache?

I am working on same app in android studio. User can download projects that contain some SVG images. He/She can download more than one project.

Those images are displayed in WebView, when the project is selected. Now every project that the user has downloaded, has an option "refresh". So I am looking for a way that it will refresh only images in my cache that belong to the selected project.

At the moment I just download the project again, but when I open the project to see the images, they are still the old ones. So, is there any way that I can refresh just some of the images in the cache? If not, are there any suggestions?

PS: I cannot delete the whole cache!

Try adding a timestamp or a version number to the url of your image which is being returned. This will disable caching. Suppose the image url is - "www.images.com/1.jpg", make it as "www.images.com/1.jpg?version=1". So when you change the version of the image file,the new file will be fetched from the server. Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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