The encrypted SharedPreferences for Android.
Secure Shared Preferences provides the features on Android 4.4 and above:
- SharedPreferences's file name encryption.
- SharedPreferences's key / value pair encryption.
Add it in your root build.gradle
at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency.
dependencies {
implementation 'com.github.ibara1454:secure-shared-preferences:v0.1.2'
}
You can use it like normal SharedPreferences.
In Kotlin,
val context = applicationContext
val preferences = context.getSecuredSharedPreferences("name", Context.MODE_PRIVATE)
or in Java,
Context context = getApplicationContext();
SharedPreferences preferences = SecureSharedPreferences.getSecureSharedPreferences(
context,
"name",
Context.MODE_PRIVATE
);
For more examples, please take a look on example.
Copyright 2020 Chiajun Wang (ibara1454).