清除由web视图创建的所有缓存的项目? [英] Clearing all cached items created by a WebView?
问题描述
我已经在我的应用程序中的web视图。当用户登出我的应用程序,我想删除所有缓存资源的WebView可能已经创建。看着一个模拟器,我看到了以下文件:
I've got a WebView in my app. When the user logs out of my app, I'd like to delete all cached resources the WebView may have created. Looking at an emulator, I see the following files:
/data
/data
/com.example.myapp
/cache
/webviewCache
bunch of files here..
/databases
webview.db
webviewCache.db
有没有系统调用,我可以用它来清除/高速缓存及/数据库中的所有元素,或者我们应该这样做手工?我担心做手工只是因为我不知道有什么新的文件的WebView背后可能离开的Android未来的版本,所以我不会肯定我真的清除一切为了用户。
Is there any system call I can use to clear all the elements in /cache and /databases, or should we do that manually? I'm worried about doing it manually just because I don't know what new files WebView may leave behind in future versions of android so I won't be sure I'm really clearing everything for the user.
推荐答案
试试这个
mWebView.clearCache(true);
mContext.deleteDatabase("webview.db");
mContext.deleteDatabase("webviewCache.db");
这篇关于清除由web视图创建的所有缓存的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!