public class

OfflineResourceConfig

extends Object
java.lang.Object
   ↳ com.salesforce.android.knowledge.core.offline.OfflineResourceConfig

Class Overview

Configuration for the Offline Resource caching mechanism.

An instance of this class must be passed to offlineResourceConfig(OfflineResourceConfig) in order to enable offline resource caching.

Resources are encrypted and cached in the application's cache directory. By default, they're stored in a `salesforce_kb` subdirectory, with an additional subdirectory for each user login.

Applications should tune the maxSize(int) and concurrentRequests(int) values to best fit the performance and business requirements of their use case. If, for example, your articles tend to include many images and you want all of them to be available offline, you may need to increase the maxSize to a value sufficiently large for storing those images; other applications may choose a smaller maxSize to minimize their disk size. If the application is programmatically pre-caching large numbers of articles, tweaking the concurrentRequests value may give better throughput and reduce the total time needed to cache the articles.

Summary

Nested Classes
class OfflineResourceConfig.Builder Builder class for OfflineResourceConfig instances. 
Protected Constructors
OfflineResourceConfig(OfflineResourceConfig.Builder builder)
Public Methods
static OfflineResourceConfig.Builder builder()
Create a OfflineResourceConfig.Builder for an OfflineResourceConfig instance using the default salesforce_kb directory within the application's cache directory.
int concurrentRequests()
The number of requests to make concurrently while downloading resources for caching.
static OfflineResourceConfig defaults()
Construct an OfflineResourceConfig with the default settings, which will create a cache with a size of 10Mb.
static OfflineResourceConfig disabled()
Construct an OfflineResourceConfig that is disabled.
boolean enabled()
Is offline resource caching enabled? If false, no resources will be cached, and the other values in this configuration may be ignored.
int maxSize()
The maximum size, in bytes, to consume on disk for caching resources.
Collection<String> mediaTypes()
The list of media types to accept into the offline cache.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected OfflineResourceConfig (OfflineResourceConfig.Builder builder)

Public Methods

public static OfflineResourceConfig.Builder builder ()

Create a OfflineResourceConfig.Builder for an OfflineResourceConfig instance using the default salesforce_kb directory within the application's cache directory.

Returns

public int concurrentRequests ()

The number of requests to make concurrently while downloading resources for caching. This is effectively the size of the threadpool to use for downloading, higher numbers can give better throughput but will consume more memory. Downloads will be queued as necessary to adhere to this value.

Returns
  • The maximum number of concurrent requests.

public static OfflineResourceConfig defaults ()

Construct an OfflineResourceConfig with the default settings, which will create a cache with a size of 10Mb.

public static OfflineResourceConfig disabled ()

Construct an OfflineResourceConfig that is disabled. No resources will be cached when using this configuration. This is the default configuration.

Returns
  • An instance that is disabled.

public boolean enabled ()

Is offline resource caching enabled? If false, no resources will be cached, and the other values in this configuration may be ignored.

Returns
  • True if caching is enabled, false if caching is disabled.
See Also

public int maxSize ()

The maximum size, in bytes, to consume on disk for caching resources.

Returns
  • The number of bytes.
See Also

public Collection<String> mediaTypes ()

The list of media types to accept into the offline cache. Files returned with a non-matching content type header will be ignored. The contents of this collection are matched against the type(), e.g. "image", "audio", etc.

Returns
  • The list of acceptable media types.