Android WebView (1)清除缓存

Android webview 遇到一种情况    每次loadurl加载一个新的页面,总会先显示上一个缓存的页面,等新的页面加载完成,才会显示新页面。
分析是由于缓存的问题,但是调用clearcache总是不管用。
后来找到了解决的办法,如下:
webView.loadDataWithBaseURL(null"","text/html""utf-8",null);  //清除缓存的有效方法 

Android.Webkit.WebView.LoadDataWithBaseURL Method
Loads the given data into this WebView, using baseUrl as the base URL for the content.

Syntax

[Android.Runtime.Register("loadDataWithBaseURL", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "GetLoadDataWithBaseURL_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler")]
public virtual  void  LoadDataWithBaseURL ( string baseUrl,  string data,  string mimeType,  string encoding,  string failUrl)
Parameters
baseUrl
the URL to use as the page's base URL. If null defaults to 'about:blank'.
data
a String of data in the given encoding
mimeType
the MIMEType of the data, e.g. 'text/html'. If null, defaults to 'text/html'.
encoding
the encoding of the data
historyUrl
the URL to use as the history entry. If null defaults to 'about:blank'. If non-null, this must be a valid URL.

Remarks

Loads the given data into this WebView, using baseUrl as the base URL for the content. The base URL is used both to resolve relative URLs and when applying JavaScript's same origin policy. The historyUrl is used for the history entry.

Note that content specified in this way can access local device files (via 'file' scheme URLs) only if baseUrl specifies a scheme other than 'http', 'https', 'ftp', 'ftps', 'about' or 'javascript'.

If the base URL uses the data scheme, this method is equivalent to calling WebView.LoadData(string, System.String, System.String) and the historyUrl is ignored, and the data will be treated as part of a data: URL. If the base URL uses any other scheme, then the data will be loaded into the WebView as a plain string (i.e. not part of a data URL) and any URL-encoded entities in the string will not be decoded.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值