要清除AutoJS中WebView的缓存,可以使用以下高级写法:

var packageName = "com.stardust.autojs";
var webViewCachePath = "/data/data/" + packageName + "/app_webview";

// 清除WebView缓存
function clearWebViewCache() {
    var file = files.cwd() + "/clearWebViewCache.sh";
    files.write(file, 'pm clear ' + packageName + '\nrm -rf ' + webViewCachePath);
    shell("sh " + file);
    files.remove(file);
}

// 调用清除WebView缓存函数
clearWebViewCache();

这段代码会在AutoJS中创建一个clearWebViewCache函数,调用该函数可以清除WebView的缓存。它会先生成一个Shell脚本文件clearWebViewCache.sh,然后使用shell函数执行该脚本文件来清除WebView的缓存。

注意:清除WebView缓存需要获取Root权限或者使用AutoJS Pro版本才能正常运行

autojs webview 清除webview缓存 高级的写法

原文地址: http://www.cveoy.top/t/topic/ican 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录