com.netmera.mobile
Class NetmeraLocalSession

java.lang.Object
  extended by com.netmera.mobile.NetmeraLocalSession

public class NetmeraLocalSession
extends java.lang.Object

This class is used to ease the use of SharedPreferences. Instead SharedPreferences, you can use this class just by calling getInstance(Context) method.


Method Summary
 boolean clearAttributes(java.lang.String sessionFileName)
          Remove all attributes saved in the given session file
 boolean contains(java.lang.String sessionFileName, java.lang.String key)
          This method checks if the given session file contains an attribute with the given key.
 java.util.Map<java.lang.String,?> getAll(java.lang.String sessionFileName)
          This method is used to get all attributes saved in given session file.
 boolean getBoolean(java.lang.String sessionFileName, java.lang.String key, boolean defValue)
          Get Boolean from session.
 float getFloat(java.lang.String sessionFileName, java.lang.String key, java.lang.Float defValue)
          Get Float from session.
static NetmeraLocalSession getInstance(android.content.Context context)
          NetmeraLocalSession is a singleton class.
 int getInteger(java.lang.String sessionFileName, java.lang.String key, int defValue)
          Get Integer from session.
 long getLong(java.lang.String sessionFileName, java.lang.String key, long defValue)
          Get Long from session.
 java.lang.String getString(java.lang.String sessionFileName, java.lang.String key, java.lang.String defValue)
          Get String from session.
 boolean isSessionFileExists(android.content.Context context, java.lang.String sessionFileName)
          Checks if the given session file exists.
 boolean put(java.lang.String sessionFileName, java.lang.String key, java.lang.Object value)
          This method puts an attribute with the given key on given session file.
 boolean removeAttribute(java.lang.String sessionFileName, java.lang.String key)
          Remove one attribute on session.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

contains

public boolean contains(java.lang.String sessionFileName,
                        java.lang.String key)
This method checks if the given session file contains an attribute with the given key.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
Returns:
true if contains.

getAll

public java.util.Map<java.lang.String,?> getAll(java.lang.String sessionFileName)
This method is used to get all attributes saved in given session file.

Parameters:
sessionFileName -
Returns:
key-value pairs for given session file.

put

public boolean put(java.lang.String sessionFileName,
                   java.lang.String key,
                   java.lang.Object value)
This method puts an attribute with the given key on given session file. As value, you can pass one of the following types. String, Long, Integer, Boolean, Float.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
value -

getString

public java.lang.String getString(java.lang.String sessionFileName,
                                  java.lang.String key,
                                  java.lang.String defValue)
Get String from session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
defValue -
Returns:
a String with the given key exists in session file. If not, return default value.

getFloat

public float getFloat(java.lang.String sessionFileName,
                      java.lang.String key,
                      java.lang.Float defValue)
Get Float from session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
defValue -
Returns:
a Float with the given key exists in session file. If not, return default value.

getInteger

public int getInteger(java.lang.String sessionFileName,
                      java.lang.String key,
                      int defValue)
Get Integer from session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
defValue -
Returns:
a Integer with the given key exists in session file. If not, return default value.

getBoolean

public boolean getBoolean(java.lang.String sessionFileName,
                          java.lang.String key,
                          boolean defValue)
Get Boolean from session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key -
defValue -
Returns:
a Boolean with the given key exists in session file. If not, return default value.

getLong

public long getLong(java.lang.String sessionFileName,
                    java.lang.String key,
                    long defValue)
Get Long from session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key - attribute key
defValue - if value can't be found, defValue will return.
Returns:
a Long with the given key exists in session file. If not, return default value.

removeAttribute

public boolean removeAttribute(java.lang.String sessionFileName,
                               java.lang.String key)
Remove one attribute on session.

Parameters:
sessionFileName - can be null, default is defined as "LocalSessionFile"
key - attribute key
Returns:
true if attribute can be deleted. false otherwise.

clearAttributes

public boolean clearAttributes(java.lang.String sessionFileName)
Remove all attributes saved in the given session file

Parameters:
sessionFileName - session file to delete
Returns:
true if attributes can be deleted, false otherwise.

isSessionFileExists

public boolean isSessionFileExists(android.content.Context context,
                                   java.lang.String sessionFileName)
Checks if the given session file exists.

Parameters:
context - a Context instance.
sessionFileName - session file to check
Returns:
true if exists, false otherwise.

getInstance

public static NetmeraLocalSession getInstance(android.content.Context context)
NetmeraLocalSession is a singleton class. To use features of this class, you can get an instance by calling this method.

Parameters:
context -
Returns:
NetmeraLocalSession instance