set Cookie by url and value - Android Network

Android examples for Network:URL

Description

set Cookie by url and value

Demo Code


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

public class Main {
    public static void setCookie(Context context, String url, String value) {
        if (context != null) {
            CookieSyncManager.createInstance(context);
            CookieManager.getInstance().setCookie(url, value);
            CookieSyncManager.getInstance().sync();
        }// w  w  w .  jav a  2  s . c om
    }
}

Related Tutorials