Android
android.webkit
public final class

android.webkit.CacheManager

java.lang.Object
android.webkit.CacheManager

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.

Nested Classes

Summary

Public Constructors

            CacheManager()

Public Methods

      static    boolean  cacheDisabled()
get the state of the current cache, enabled or disabled
      static    boolean  cacheEmpty()
Return true if the cache is empty.
      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    boolean  removeAllCacheFiles()
remove all cache files
      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    void  setCacheDisabled(boolean disabled)
set the flag to control whether cache is enabled or disabled
      static    void  trimCacheIfNeeded()
Methods inherited from class java.lang.Object

Details

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 cacheEmpty()

Return true if the cache is empty.

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 boolean removeAllCacheFiles()

remove all cache files

Returns

  • true if it succeeds

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 void setCacheDisabled(boolean disabled)

set the flag to control whether cache is enabled or disabled

Parameters

disabled true to disable the cache

public static void trimCacheIfNeeded()

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48