com.funambol.storage
Class StringKeyValueSQLiteStore

java.lang.Object
  extended by com.funambol.storage.StringKeyValueSQLiteStore
All Implemented Interfaces:
StringKeyValueStore

public class StringKeyValueSQLiteStore
extends java.lang.Object
implements StringKeyValueStore

Allows a key-value pairs to be stored to a SQLite database through the Android APIs.


Nested Class Summary
 class StringKeyValueSQLiteStore.DatabaseHelper
          Helps on creating and upgrading the SQLite db.
 
Constructor Summary
StringKeyValueSQLiteStore(Context c, java.lang.String dbName, java.lang.String tableName)
          Create a new StringKeyValueSQLiteStore given the Context the database file name and the table name.
 
Method Summary
 void add(java.lang.String key, java.lang.String value)
          Add a new item into the store.
 boolean contains(java.lang.String key)
          Returns true iff key is contained in this store.
 java.lang.String get(java.lang.String key)
          Returns the value associated to the given key or null if not present.
 java.util.Enumeration keys()
          Returns an enumeration with all the keys in the store.
 java.util.Enumeration keyValuePairs()
          Returns an enumeration of all the key/value pairs in the store.
 void load()
          Load this store into memory.
 java.lang.String put(java.lang.String key, java.lang.String value)
          Deprecated method.
 java.lang.String remove(java.lang.String key)
          Removes an entry from the store
 void reset()
          Resets this data store.
 void save()
          Save the current store.
 void update(java.lang.String key, java.lang.String value)
          Update and existing item into the store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringKeyValueSQLiteStore

public StringKeyValueSQLiteStore(Context c,
                                 java.lang.String dbName,
                                 java.lang.String tableName)
Create a new StringKeyValueSQLiteStore given the Context the database file name and the table name.

Parameters:
c - The Context.
dbName - The database file name.
tableName - The table name.
Method Detail

add

public void add(java.lang.String key,
                java.lang.String value)
Description copied from interface: StringKeyValueStore
Add a new item into the store. The item is not persisted but it is cached. Clients should invoke the save method to persist changes.

Specified by:
add in interface StringKeyValueStore
Parameters:
key - the unique key for this item (cannot be null)
value - the value to be stored
See Also:
StringKeyValueStore.add(java.lang.String, java.lang.String)

update

public void update(java.lang.String key,
                   java.lang.String value)
Description copied from interface: StringKeyValueStore
Update and existing item into the store. The item is not persisted but it is cached. Clients should invoke the save method to persist changes.

Specified by:
update in interface StringKeyValueStore
Parameters:
key - the unique key of the existing item
value - the value to be stored
See Also:
StringKeyValueStore.update(java.lang.String, java.lang.String)

put

public java.lang.String put(java.lang.String key,
                            java.lang.String value)
                     throws java.lang.Exception
Deprecated method. Throws always an Exception.

Specified by:
put in interface StringKeyValueStore
Parameters:
key - the unique key for this item (cannot be null)
value - the value to be stored
Returns:
the old value associated to this key (null if it was not present)
Throws:
java.lang.Exception - if the operation can't be performed

get

public java.lang.String get(java.lang.String key)
Description copied from interface: StringKeyValueStore
Returns the value associated to the given key or null if not present.

Specified by:
get in interface StringKeyValueStore
Parameters:
key - is the key (cannot be null)
Returns:
the value in the store or null if not present
See Also:
StringKeyValueStore.get(java.lang.String)

keys

public java.util.Enumeration keys()
Description copied from interface: StringKeyValueStore
Returns an enumeration with all the keys in the store. The elements type is String.

Specified by:
keys in interface StringKeyValueStore
Returns:
the keys
See Also:
StringKeyValueStore.keys()

keyValuePairs

public java.util.Enumeration keyValuePairs()
Description copied from interface: StringKeyValueStore
Returns an enumeration of all the key/value pairs in the store. The elements type is KeyValuePair.

Specified by:
keyValuePairs in interface StringKeyValueStore
Returns:
the key/value pairs
See Also:
StringKeyValueStore.keyValuePairs()

contains

public boolean contains(java.lang.String key)
Description copied from interface: StringKeyValueStore
Returns true iff key is contained in this store.

Specified by:
contains in interface StringKeyValueStore
See Also:
StringKeyValueStore.contains(java.lang.String)

remove

public java.lang.String remove(java.lang.String key)
Description copied from interface: StringKeyValueStore
Removes an entry from the store

Specified by:
remove in interface StringKeyValueStore
Parameters:
key - the item key
Returns:
the value associated to the item being deleted or null if the item is not in the store
See Also:
StringKeyValueStore.remove(java.lang.String)

save

public void save()
          throws java.io.IOException
Save the current store. Ends a successfull transaction.

Specified by:
save in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation cannot be performed
See Also:
StringKeyValueStore.save()

load

public void load()
          throws java.io.IOException
Description copied from interface: StringKeyValueStore
Load this store into memory.

Specified by:
load in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation cannot be performed
See Also:
StringKeyValueStore.load()

reset

public void reset()
           throws java.io.IOException
Description copied from interface: StringKeyValueStore
Resets this data store. All data is lost after this call.

Specified by:
reset in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation fails
See Also:
StringKeyValueStore.reset()


Copyright © 2001-2009 Funambol.