List of usage examples for android.webkit WebViewDatabase getInstance
public static WebViewDatabase getInstance(Context context)
From source file:Main.java
public static void clearFormData(Context context) { WebViewDatabase db = WebViewDatabase.getInstance(context); if (db.hasFormData()) { db.clearFormData();//from ww w . j a va 2s . c om } if (db.hasHttpAuthUsernamePassword()) { db.clearHttpAuthUsernamePassword(); } if (db.hasUsernamePassword()) { db.clearUsernamePassword(); } }
From source file:android.webkit.cts.WebViewTest.java
@UiThreadTest public void testAccessHttpAuthUsernamePassword() { if (!NullWebViewUtils.isWebViewAvailable()) { return;/*w ww . java2 s . co m*/ } try { WebViewDatabase.getInstance(getActivity()).clearHttpAuthUsernamePassword(); String host = "http://localhost:8080"; String realm = "testrealm"; String userName = "user"; String password = "password"; String[] result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNull(result); mWebView.setHttpAuthUsernamePassword(host, realm, userName, password); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertEquals(userName, result[0]); assertEquals(password, result[1]); String newPassword = "newpassword"; mWebView.setHttpAuthUsernamePassword(host, realm, userName, newPassword); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertEquals(userName, result[0]); assertEquals(newPassword, result[1]); String newUserName = "newuser"; mWebView.setHttpAuthUsernamePassword(host, realm, newUserName, newPassword); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertEquals(newUserName, result[0]); assertEquals(newPassword, result[1]); // the user is set to null, can not change any thing in the future mWebView.setHttpAuthUsernamePassword(host, realm, null, password); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertNull(result[0]); assertEquals(password, result[1]); mWebView.setHttpAuthUsernamePassword(host, realm, userName, null); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertEquals(userName, result[0]); assertEquals(null, result[1]); mWebView.setHttpAuthUsernamePassword(host, realm, null, null); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertNull(result[0]); assertNull(result[1]); mWebView.setHttpAuthUsernamePassword(host, realm, newUserName, newPassword); result = mWebView.getHttpAuthUsernamePassword(host, realm); assertNotNull(result); assertEquals(newUserName, result[0]); assertEquals(newPassword, result[1]); } finally { WebViewDatabase.getInstance(getActivity()).clearHttpAuthUsernamePassword(); } }
From source file:com.dish.browser.activity.BrowserActivity.java
@SuppressWarnings("deprecation") public void clearHistory() { this.deleteDatabase(HistoryDatabase.DATABASE_NAME); WebViewDatabase m = WebViewDatabase.getInstance(this); m.clearFormData();/* ww w. j a va 2 s .com*/ m.clearHttpAuthUsernamePassword(); if (API < 18) { m.clearUsernamePassword(); WebIconDatabase.getInstance().removeAllIcons(); } if (mSystemBrowser) { try { Browser.clearHistory(getContentResolver()); } catch (NullPointerException ignored) { } } Utils.trimCache(this); }