본문 바로가기
개발/안드로이드

안드로이드 웹뷰 쿠키, 세션, 히스토리 삭제

by darksilber 2020. 10. 24.
반응형

 

 webView.clearCache(true);
 webView.clearHistory();
 
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
  CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(MainActivity.this);
  cookieSyncMngr.startSync();
  CookieManager cookieManager=CookieManager.getInstance();
  cookieManager.removeAllCookie();
  cookieManager.removeSessionCookie();
  cookieSyncMngr.stopSync();
  cookieSyncMngr.sync();
}else {
  CookieManager cookieManager = CookieManager.getInstance();
  cookieManager.removeAllCookies(new ValueCallback() {
        @Override
        public void onReceiveValue(Boolean value) {
        Log.d("onReceiveValue", value.toString());
        }
	});
	cookieManager.getInstance().flush();
}

 

반응형

댓글