Skip to content

ibara1454/secure-shared-preferences

Repository files navigation

Secure shared preferences

Codacy Badge Jitpack codecov License: MIT

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.

Installation

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'
}

Usage

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.

License

MIT

Copyright 2020 Chiajun Wang (ibara1454).