oak
Class ObscuredSharedPreferences

java.lang.Object
  extended by oak.ObscuredSharedPreferences
All Implemented Interfaces:
android.content.SharedPreferences

public abstract class ObscuredSharedPreferences
extends Object
implements android.content.SharedPreferences

This code originally posted by Michael Burton on StackOverflow http://stackoverflow.com/questions/785973/what-is-the-most-appropriate-way-to-store-user-settings-in-android-application/6393502#6393502


Nested Class Summary
 class ObscuredSharedPreferences.Editor
           
 
Nested classes/interfaces inherited from interface android.content.SharedPreferences
android.content.SharedPreferences.OnSharedPreferenceChangeListener
 
Field Summary
protected  android.content.Context context
           
protected  android.content.SharedPreferences delegate
           
protected static String UTF8
           
 
Constructor Summary
ObscuredSharedPreferences(android.content.Context context, android.content.SharedPreferences delegate)
           
 
Method Summary
 boolean contains(String s)
           
protected  String decrypt(String value)
           
 ObscuredSharedPreferences.Editor edit()
           
protected  String encrypt(String value)
           
 Map<String,?> getAll()
           
 boolean getBoolean(String key, boolean defValue)
           
 float getFloat(String key, float defValue)
           
 int getInt(String key, int defValue)
           
 long getLong(String key, long defValue)
           
protected abstract  char[] getSpecialCode()
          Implement this method to supply your char array with your password
 String getString(String key, String defValue)
           
 void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
           
 void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.content.SharedPreferences
getStringSet
 

Field Detail

UTF8

protected static final String UTF8
See Also:
Constant Field Values

delegate

protected android.content.SharedPreferences delegate

context

protected android.content.Context context
Constructor Detail

ObscuredSharedPreferences

public ObscuredSharedPreferences(android.content.Context context,
                                 android.content.SharedPreferences delegate)
Method Detail

getSpecialCode

protected abstract char[] getSpecialCode()
Implement this method to supply your char array with your password

Returns:

edit

public ObscuredSharedPreferences.Editor edit()
Specified by:
edit in interface android.content.SharedPreferences

getAll

public Map<String,?> getAll()
Specified by:
getAll in interface android.content.SharedPreferences

getBoolean

public boolean getBoolean(String key,
                          boolean defValue)
Specified by:
getBoolean in interface android.content.SharedPreferences

getFloat

public float getFloat(String key,
                      float defValue)
Specified by:
getFloat in interface android.content.SharedPreferences

getInt

public int getInt(String key,
                  int defValue)
Specified by:
getInt in interface android.content.SharedPreferences

getLong

public long getLong(String key,
                    long defValue)
Specified by:
getLong in interface android.content.SharedPreferences

getString

public String getString(String key,
                        String defValue)
Specified by:
getString in interface android.content.SharedPreferences

contains

public boolean contains(String s)
Specified by:
contains in interface android.content.SharedPreferences

registerOnSharedPreferenceChangeListener

public void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
Specified by:
registerOnSharedPreferenceChangeListener in interface android.content.SharedPreferences

unregisterOnSharedPreferenceChangeListener

public void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
Specified by:
unregisterOnSharedPreferenceChangeListener in interface android.content.SharedPreferences

encrypt

protected String encrypt(String value)

decrypt

protected String decrypt(String value)


Copyright © 2011-2014. All Rights Reserved.