Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 1.34 KB

README.md

File metadata and controls

60 lines (39 loc) · 1.34 KB

SafeDepositBox

This is a Wrapper for EncryptedSharedPreferences, it simplify preferences implementation for storing value/s.

Value/s Support

This can store more value/s type such as String, List<String>, Float, List<Float>, Double, List<Double>, Boolean, List<Boolean>, Object, List<Object>

Usage

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'

Examples

Store String

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")

Store Object

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")