Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.Build; import android.webkit.CookieManager; import android.webkit.CookieSyncManager; public class Main { @SuppressWarnings("deprecation") public static void clearCookies(Context context) { if (Build.VERSION.SDK_INT >= 21) { try { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } catch (Exception e) { } } else { try { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } catch (Exception e) { } } } }