科尔多瓦Web视图缓存的Andr​​oid清晰 [英] Cordova Web view cache clear in android

查看:290
本文介绍了科尔多瓦Web视图缓存的Andr​​oid清晰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图清除存储在它使用的WebView科尔多瓦android应用缓存。
我试着用 cordovaWebView.clearCache(真); 还与

I am trying to clear the cache stored in android application which uses cordova webview. I tried with cordovaWebView.clearCache(true); Also tried with

public void deleteCache(Context context) {
        Log.i("Utility", "deleting Cache");
        try {
            File dir = context.getCacheDir();
            if (dir != null && dir.isDirectory()) {
                deleteDir(dir);
            }
        } catch (Exception e) {
            Log.e("Utility", " exception in deleting cookies");
        }

    }


public static boolean deleteDir(File dir) {
        if (dir != null && dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        } else if (dir != null && dir.isFile()) {
            dir.delete(); // delete the file INSIDE the directory
        }
        Log.i("Utility", "deleting Cache " + dir.delete());
        return true;
    }

但都没有工作。
我可以得到任何解决方案,这一点,因为在网上查看用户使用登录,因此我们需要清除缓存加载应用程序第二遍的时候。

But both didnt work. May I get any solution for this, as in web view user use to login and hence we need to clear the cache when loading the app second time.

推荐答案

最简单的答案,这是

cordovaWebView.clearCache(true);
 android.webkit.CookieManager.getInstance().removeAllCookie();

cordovaWebView是Cordovawebview的实例。

cordovaWebView is the instance of Cordovawebview.

使用两者。

这篇关于科尔多瓦Web视图缓存的Andr​​oid清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆