您的位置:首页 > 移动开发 > Android开发

eclipse下导入app源代码无法编译import android.webkit.CacheManager;类的问题

2016-12-21 22:17 435 查看
错误现象:

import android.webkit.CacheManager;

public void clearAppCache() {
// 清除webview缓存
File file = CacheManager.getCacheFileBaseDir();
if (file != null && file.exists() && file.isDirectory()) {
for (File item : file.listFiles()) {
item.delete();
}
file.delete();
}

出现原因是:此类已弃用。 将来的版本中将会删除对HTTP缓存的访问。

This class is deprecated.
Access to the HTTP cache will be removed in a future release.

参考API:http://www.android-doc.com/reference/android/webkit/CacheManager.html

解决方案是:

降低项目的编译SDK版本

project.properties 里面 Android版本改到15试试~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: