public final class

CacheManager

extends Object
java.lang.Object
   ↳ android.webkit.CacheManager

Class Overview

The class CacheManager provides the persistent cache of content that is received over the network. The component handles parsing of HTTP headers and utilizes the relevant cache headers to determine if the content should be stored and if so, how long it is valid for. Network requests are provided to this component and if they can not be resolved by the cache, the HTTP headers are attached, as appropriate, to the request for revalidation of content. The class also manages the cache size.

Summary

Nested Classes
public final class CacheManager.CacheResult  
Public Constructors
CacheManager()
Public Methods
static boolean cacheDisabled()
get the state of the current cache, enabled or disabled
static boolean endCacheTransaction()
static CacheManager.CacheResult getCacheFile(String url, Map<StringString> headers)
Given a url, returns the CacheResult if exists.
static File getCacheFileBaseDir()
get the base directory of the cache.
static void saveCacheFile(String url, CacheManager.CacheResult cacheRet)
Save the info of a cache file for a given url to the CacheMap so that it can be reused later
static boolean startCacheTransaction()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CacheManager ()

Public Methods

public static boolean cacheDisabled ()

get the state of the current cache, enabled or disabled

Returns
  • return if it is disabled

public static boolean endCacheTransaction ()

public static CacheManager.CacheResult getCacheFile (String url, Map<StringString> headers)

Given a url, returns the CacheResult if exists. Otherwise returns null. If headers are provided and a cache needs validation, HEADER_KEY_IFNONEMATCH or HEADER_KEY_IFMODIFIEDSINCE will be set in the cached headers.

Returns
  • the CacheResult for a given url

public static File getCacheFileBaseDir ()

get the base directory of the cache. With localPath of the CacheResult, it identifies the cache file.

Returns
  • File The base directory of the cache.

public static void saveCacheFile (String url, CacheManager.CacheResult cacheRet)

Save the info of a cache file for a given url to the CacheMap so that it can be reused later

public static boolean startCacheTransaction ()