A quickly useful Shared preferences tool
This tool can instantiates a sharedpreference file, you don't need to maintain the sp table names and the sp keys.
- Use @SpTable annotate an interface to create a sharedpreference file.
- Define some method in this interface, the method name is the default sharedpreference key or you can annotate the method with @SpKey to modify the key.
- All the methods in your interface should return an Option with the generic paradigm of some type supported by shared preference
- The Option object can get and set the sp value.
- Use SpManager.provideInstance() to create an instance of your sharedprefenrence table object.
Add the following Gradle configuration to your Android project. In your root build.gradle file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
In your app modules app/build.gradle file:
dependencies {
implementation 'com.github.zhangsiqigithub:NiceSp:1.0.0' // add library
}