org.codeforamerica.open311.internals.caching
Class AndroidCache

java.lang.Object
  extended by org.codeforamerica.open311.internals.caching.AbstractCache
      extended by org.codeforamerica.open311.internals.caching.AndroidCache
All Implemented Interfaces:
Cache

public class AndroidCache
extends AbstractCache

Uses the SharedPreferences of Android to store the data. Singleton class.

Author:
Santiago MunĂ­n

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.codeforamerica.open311.internals.caching.Cache
Cache.CacheableOperation
 
Field Summary
 
Fields inherited from class org.codeforamerica.open311.internals.caching.AbstractCache
FILE
 
Method Summary
 void deleteCache()
          Deletes the cache.
static AndroidCache getInstance(android.content.Context context)
          Returns the unique instance of the class.
protected  String getProperty(String key)
          Retrieves a property.
protected  void saveProperty(String key, String value)
          Saves a property.
 
Methods inherited from class org.codeforamerica.open311.internals.caching.AbstractCache
retrieveCachedServiceDefinition, retrieveCachedServiceDiscoveryInfo, retrieveCachedServiceList, retrieveCachedServiceRequest, retrieveCachedServiceRequests, retrieveCitiesInfo, saveCitiesInfo, saveListOfServices, saveServiceDefinition, saveServiceDiscovery, saveServiceRequestList, saveSingleServiceRequest, setCustomTimeToLive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static AndroidCache getInstance(android.content.Context context)
Returns the unique instance of the class.

Parameters:
context - Android context. Needed the first time is called to build the SharedPreferences.
Returns:
Unique instance of the class.

deleteCache

public void deleteCache()
Description copied from interface: Cache
Deletes the cache.


saveProperty

protected void saveProperty(String key,
                            String value)
Description copied from class: AbstractCache
Saves a property. The given parameters must be valid strings with content (empty or null strings are not allowed).

Specified by:
saveProperty in class AbstractCache
Parameters:
key - Key of the property.
value - Value of the property.

getProperty

protected String getProperty(String key)
Description copied from class: AbstractCache
Retrieves a property.

Specified by:
getProperty in class AbstractCache
Parameters:
key - Key of the property (empty or null strings are not allowed).
Returns:
The property value of null if the key doesn't exist.


Copyright © 2013 Code for America. All Rights Reserved.