在浏览器中删除数据 [英] Delete data in the browser

查看:219
本文介绍了在浏览器中删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以删除应用程序的信息资料,要永久删除数据时,应用程序被终止。然而,该数据不能被完全除去。你知道这个问题是从这个来源是什么?

 上下文的背景下= getBaseContext();
的WebView的WebView =新的WebView(背景);deleteCacheDir(本);
clearApplicationCache(NULL);。CookieManager.getInstance()removeAllCookie();的String [] =的fileList this.fileList();
    对于(字符串的文件:的fileList){
    this.deleteFile(文件);
}
WebViewDatabase.getInstance(本).clearUsernamePassword();
WebViewDatabase.getInstance(本).clearHttpAuthUsernamePassword();webview.clearSsl preferences();
webview.clearView();webview.clearFormData();
webview.clearHistory();
webview.clearCache(真);
webview.clearMatches();context.deleteDatabase(/数据/数据​​/ android.Packege / databaseswebview.db
context.deleteDatabase(/数据/数据​​/ android.Packege /数据库/ webviewCache.db);webview.freeMemory();android.os.Process.killProcess(android.os.Process.myPid());
返回true;
}
返回true;
}
私人无效clearApplicationCache(java.io.File中的DIR){
如果(DIR == NULL)
    DIR = getCacheDir();
其他;
    如果(DIR == NULL)
    返回;
其他;
    java.io.File中的[] =儿童dir.listFiles();
    尝试{
        的for(int i = 0; I< children.length;我++)
        如果(孩子[我] .isDirectory())
        clearApplicationCache(儿童[I]);
        别的孩子[我] .delete();
    }
    赶上(例外五){}
}
无效deleteCacheDir(上下文的背景下){
    运行时localRuntime =调用Runtime.getRuntime();    字符串cachePath = context.getCacheDir()的getPath()。
    字符串CMD =RM -R+ cachePath;
    尝试{
        localRuntime.exec(CMD);
    }赶上(IOException异常五){
        e.printStackTrace();
        }
    }


解决方案

难道您键入 android.Packege 而不是 android.Package

I can delete data from the application information, you want to permanently delete the data when the application was terminated. However, the data can not be removed completely. Do you know what the problem is from this source?

Context context = getBaseContext();
WebView webview = new WebView(context);

deleteCacheDir(this);
clearApplicationCache(null);

CookieManager.getInstance().removeAllCookie();

String[] fileList = this.fileList();
    for(String file: fileList) { 
    this.deleteFile(file);
}
WebViewDatabase.getInstance(this).clearUsernamePassword();
WebViewDatabase.getInstance(this).clearHttpAuthUsernamePassword();

webview.clearSslPreferences();
webview.clearView();

webview.clearFormData();
webview.clearHistory();
webview.clearCache(true);
webview.clearMatches();

context.deleteDatabase("/data/data/android.Packege/databaseswebview.db"
context.deleteDatabase("/data/data/android.Packege/databases/webviewCache.db");

webview.freeMemory();

android.os.Process.killProcess(android.os.Process.myPid());
return true;
}
return true;
}
private void clearApplicationCache(java.io.File dir){
if(dir==null)
    dir = getCacheDir();
else;
    if(dir==null)
    return;
else;
    java.io.File[] children = dir.listFiles();
    try{
        for(int i=0;i<children.length;i++)
        if(children[i].isDirectory())
        clearApplicationCache(children[i]);
        else children[i].delete();
    }
    catch(Exception e){}
}
void deleteCacheDir(Context context) {
    Runtime localRuntime = Runtime.getRuntime();

    String cachePath = context.getCacheDir().getPath();
    String cmd = "rm -R " + cachePath;
    try {
        localRuntime.exec(cmd);
    } catch (IOException e) {
        e.printStackTrace();
        }
    }

解决方案

Could it be that you typed android.Packege instead of android.Package ?

这篇关于在浏览器中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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