user1861240 user1861240 - 17 days ago 6
Android Question

How to clear logon credentials from WebView?

I want to clear application data like i can do it from settings. I need to clear login information in WebView when i am login to facebook or twitter, because when i log on once for each of the following uses the same data automatically

I try this:
http://www.hrupin.com/2011/11/how-to-clear-user-data-in-your-android-application-programmatically

didn't work, login information are still in browser

I try reset app:

Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);


also

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
view.clearCache(true);

if(b){
Log.d("WEBVIEW", "onFinisghed b true");
Map<String, String> noCacheHeaders = new HashMap<String, String>(2);
noCacheHeaders.put("Pragma", "no-cache");
noCacheHeaders.put("Cache-Control", "no-cache");
view.loadUrl(url, noCacheHeaders);
b = false;
}...


Most of the entries refers to the first method which is described in the link, but it does not work in my case, any ideas?

Answer

Try clearing the browser cookies, e.g.

CookieManager.getInstance().removeAllCookie();

CookieManager documentation is here.

Comments