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?
Try clearing the browser cookies. Logon credentials are often stored in browser cookies, which you can delete by a call to
CookieManager.getInstance().removeAllCookie();
Update:
CookieManager.getInstance().removeAllCookie() was deprecated in Android SDK 21 (Lollipop), and was replaced by CookieManager.getInstance().removeAllCookies(ValueCallback callback). As of November 2018, removeAllCookie() stills works as specified. Also, in the newer method removeAllCookies(ValueCallback callback), the callback function can be null if you don't want to be notified about removed cookies. Thus, it's safe to use
CookieManager.getInstance().removeAllCookies(null)
as a direct replacement for CookieManager.getInstance().removeAllCookie() when targeting devices after Android SDK 21.
CookieManager documentation is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With