public class SecurePreferences
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SecurePreferences.SecurePreferencesException |
Constructor and Description |
---|
SecurePreferences(android.content.Context context,
java.lang.String preferenceName,
java.lang.String secureKey,
boolean encryptKeys)
This will initialize an instance of the SecurePreferences class
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.String key) |
java.lang.String |
getString(java.lang.String key) |
void |
put(java.lang.String key,
java.lang.String value) |
void |
removeValue(java.lang.String key) |
public SecurePreferences(android.content.Context context, java.lang.String preferenceName, java.lang.String secureKey, boolean encryptKeys) throws SecurePreferences.SecurePreferencesException
context
- your current context.preferenceName
- name of preferences file (preferenceName.xml)secureKey
- the key used for encryption, finding a good key scheme is hard.
Hardcoding your key in the application is bad, but better than plaintext preferences. Having the user enter the key upon application launch is a safe(r) alternative, but annoying to the user.encryptKeys
- settings this to false will only encrypt the values,
true will encrypt both values and keys. Keys can contain a lot of information about
the plaintext value of the value which can be used to decipher the value.SecurePreferences.SecurePreferencesException
public void put(java.lang.String key, java.lang.String value)
public boolean containsKey(java.lang.String key)
public void removeValue(java.lang.String key)
public java.lang.String getString(java.lang.String key) throws SecurePreferences.SecurePreferencesException
public void clear()