下面列出了怎么用android.webkit.WebViewDatabase的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("deprecation")
public void clearHistory() {
this.deleteDatabase(HistoryDatabase.DATABASE_NAME);
WebViewDatabase m = WebViewDatabase.getInstance(this);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (API < 18) {
m.clearUsernamePassword();
WebIconDatabase.getInstance().removeAllIcons();
}
if (mSystemBrowser) {
try {
//Browser.
//Browser.clearHistory(getContentResolver());
} catch (NullPointerException ignored) {
}
}
Utils.trimCache(this);
}
/**
* Clears browser cache etc
*/
protected void clearTraces(){
CustomWebView WV = webLayout.findViewById(R.id.browser_page);
if (WV!=null){
WV.clearHistory();
WV.clearCache(true);
}
WebViewDatabase wDB = WebViewDatabase.getInstance(activity);
wDB.clearFormData();
CookieSyncManager.createInstance(activity);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
// Usefull for future commits:
// cookieManager.setAcceptCookie(false)
//
// WebView webview = new WebView(this);
// WebSettings ws = webview.getSettings();
// ws.setSaveFormData(false);
// ws.setSavePassword(false); // Not needed for API level 18 or greater (deprecat
}
/**
* Clear the web database
*/
public void clearDatabase() {
WebViewDatabase database = WebViewDatabase.getInstance(getContext());
database.clearHttpAuthUsernamePassword();
database.clearFormData();
database.clearUsernamePassword();
}
public static void clearHistory(@NonNull Context context, @NonNull HistoryModel historyModel) {
historyModel.deleteHistory()
.subscribeOn(Schedulers.io())
.subscribe();
WebViewDatabase m = WebViewDatabase.getInstance(context);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
//noinspection deprecation
m.clearUsernamePassword();
//noinspection deprecation
WebIconDatabase.getInstance().removeAllIcons();
}
Utils.trimCache(context);
}
public static void clearAll(WebView webView) {
clearCookie();
if (webView != null) {
webView.clearCache(true);
}
WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(MainApplication.getInstance());
webViewDatabase.clearFormData();
webViewDatabase.clearHttpAuthUsernamePassword();
WebStorage.getInstance().deleteAllData();
}
public static void clearHistory(@NonNull Context context, @NonNull HistoryModel historyModel) {
historyModel.deleteHistory()
.subscribeOn(Schedulers.io())
.subscribe();
WebViewDatabase m = WebViewDatabase.getInstance(context);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
//noinspection deprecation
m.clearUsernamePassword();
//noinspection deprecation
WebIconDatabase.getInstance().removeAllIcons();
}
Utils.trimCache(context);
}