Skip to content

Most visited

Recently visited

navigation
Added in API level 9

CookieStore

public interface CookieStore

java.net.CookieStore


A CookieStore object is a repository for cookies. CookieManager will store cookies of every incoming HTTP response into CookieStore, and retrieve cookies for every outgoing HTTP request.Expired HttpCookies should be removed from this store by themselves.

Summary

Public methods

abstract void add(URI uri, HttpCookie cookie)

Saves a HTTP cookie to this store.

abstract List<HttpCookie> get(URI uri)

Retrieves cookies that match the specified URI.

abstract List<HttpCookie> getCookies()

Get all cookies in cookie store which are not expired.

abstract List<URI> getURIs()

Get a set of URIs, which is composed of associated URI with all the cookies in the store.

abstract boolean remove(URI uri, HttpCookie cookie)

Remove the specified cookie from the store.

abstract boolean removeAll()

Clear this cookie store.

Public methods

add

Added in API level 9
void add (URI uri, 
                HttpCookie cookie)

Saves a HTTP cookie to this store. This is called for every incoming HTTP response. A cookie may or may not has an associated URI. If not, the cookie's domain and path attribute will show cradleland. If there is an associated URI and no domain and path attribute are speicifed for the cookie, the given URI will indicate where this cookie comes from. If a cookie corresponding to the given URI already exists, then it is replaced with the new one.

Parameters
uri URI: the uri associated with the specified cookie. A null value indicates the cookie is not associated with a URI
cookie HttpCookie: the cookie to be stored

get

Added in API level 9
List<HttpCookie> get (URI uri)

Retrieves cookies that match the specified URI. Return not expired cookies. For every outgoing HTTP request, this method will be called.

Parameters
uri URI: the uri this cookie associated with. If null, this cookie will not be associated with an URI
Returns
List<HttpCookie> an immutable list of HttpCookies, return empty list if no cookies match the given URI
Throws
NullPointerException if uri is null

getCookies

Added in API level 9
List<HttpCookie> getCookies ()

Get all cookies in cookie store which are not expired.

Returns
List<HttpCookie> an empty list if there's no http cookie in store, or an immutable list of cookies

getURIs

Added in API level 9
List<URI> getURIs ()

Get a set of URIs, which is composed of associated URI with all the cookies in the store.

Returns
List<URI> zero-length list if no cookie in the store is associated with any URIs, otherwise an immutable list of URIs.

remove

Added in API level 9
boolean remove (URI uri, 
                HttpCookie cookie)

Remove the specified cookie from the store.

Parameters
uri URI: the uri associated with the specified cookie. If the cookie is not associated with an URI when added, uri should be null; otherwise the uri should be non-null.
cookie HttpCookie: the cookie to be removed
Returns
boolean true if the specified cookie is contained in this store and removed successfully

removeAll

Added in API level 9
boolean removeAll ()

Clear this cookie store.

Returns
boolean true if any cookies were removed as a result of this call.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.