且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android WebView缓存

更新时间:2023-11-27 19:07:16

是,使用 shouldInterceptRequest 。您可以使用它来检测是否具有请求的URL的缓存版本,并将输入流返回到WebView将使用的缓存中,而不是从ze webz加载它。

Yes, using shouldInterceptRequest. Which you can use to detect if you have a cached version of the requested URL and return an input stream to the cache which the WebView will use instead of loading it from ze webz

对于蜂窝版之前的版本,可能可以使用 shouldOverrideUrlLoading ,调用 webview.loadData(datafromcache, text / html, UTF-8); 并返回true。

For versions before honeycomb, it might be possible to use shouldOverrideUrlLoading, calling webview.loadData(datafromcache, "text/html", "UTF-8"); and return true.