如何完全禁用Android webView缓存

问题描述 投票:0回答:1

我在应用程序中使用WebView,并且已通过以下两行禁用了缓存:

mWebView.getSettings().setAppCacheEnabled(false);
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

[当应用加载WebView时,它会显示一个登录页面,而这里的奇怪行为是该页面在用户首次登录后就记住了该用户(尽管添加了两行)。另一个相关的一点是,如果我删除应用程序数据,将不再记得该用户。

所以,该用户被保存在哪里?如何防止保存此信息?据我了解,由于已将其禁用,因此未保存在缓存中。

编辑:只是为了澄清我不想删除数据,我需要的是应用程序不会生成数据。

android caching android-webview
1个回答
0
投票

我也遇到过同样的情况,并且不是Cache问题,而是Cookie问题,我删除了

CookieSyncManager.createInstance(this);         
CookieManager cookieManager = CookieManager.getInstance();        
cookieManager.removeAllCookie();

也可以看看WebStorage.getInstance().deleteAllData();

参考:How to clear all WebView stored information?


0
投票

我也遇到过同样的情况,并且不是Cache问题,而是Cookie问题,我删除了

CookieSyncManager.createInstance(this);         
CookieManager cookieManager = CookieManager.getInstance();        
cookieManager.removeAllCookie();
© www.soinside.com 2019 - 2024. All rights reserved.