This is a Wrapper for EncryptedSharedPreferences, it simplify preferences implementation for storing value/s.
This can store more value/s type such as String, List<String>, Float, List<Float>, Double, List<Double>, Boolean, List<Boolean>, Object, List<Object>
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the library to your apps build.gradle:
implementation 'com.github.RazibKani:SafeDepositBox:0.4'
val safeDepositBox = SafeDepositBox(context, "SafeDepositBoxSample")
// store string
safeDepositBox.storeString("tatang", "Tatang Sutarna")
// get string without default value, it will return null if no value with key "tatang"
val tatang = safeDepositBox.getString("tatang")
// get string with default value, it will return default value if no value with key "tatang"
val tatang = safeDepositBox.getString("tatang", "Default Tatang")
val safeDepositBox = SafeDepositBox(context, "SafeDepositBoxSample")
// create object user
val tatang = User("tatang", "sutarna")
// store object user
safeDepositBox.storeObject("tatang", tatang)
// get object user
val userTatang = safeDepositBox.getObject<User>("tatang")