Android的安全简单Key-Value存储:Hawk
jopen
10年前
Android的安全、简单Key-Value存储
Hawk uses:
- AES for the crypto
- SharedPreferences for the storage
- Gson
Hawk provides:
- Secure data persistence
- Save any type
- Save list of any type
Add dependency
repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots/"} } dependencies { compile 'com.orhanobut:hawk:1.3-SNAPSHOT' }
Initialize the hawk
Hawk.init(context);
Save
Hawk.put(key, ANYTHING);
Get
T result = Hawk.get(key);
or with default value
T result = Hawk.get(key, T);
Remove
Hawk.remove(key);
Contains
boolean contains = Hawk.contains(key);