clear Cookies with CookieManager - Android Network

Android examples for Network:Cookie

Description

clear Cookies with CookieManager

Demo Code


//package com.java2s;
import android.content.Context;
import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;

public class Main {
    public static void clearCookies(Context context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            CookieSyncManager.createInstance(context);
            CookieSyncManager.getInstance().startSync();
        }/*from  w  w w  .  j a  v  a 2 s. c  o m*/
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            CookieManager.getInstance().removeAllCookies(null);
        } else {
            CookieManager.getInstance().removeAllCookie();
        }
    }
}

Related Tutorials