Security SharedPreferences support min sdk 21+
build.gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
build.gradle
- Read and Write key-value
dependencies {
implementation("com.github.developersancho.prefstore:prefstore:1.0.0")
}
- Read and Write key-value, Support
Moshi Serialize-Deserialize
dependencies {
implementation("com.github.developersancho.prefstore:prefstore-moshi:1.0.0")
}
- Read and Write key-value, Support
Gson Serialize-Deserialize
dependencies {
implementation("com.github.developersancho.prefstore:prefstore-gson:1.0.0")
}
- Read and Write key-value, Support
Both of Moshi-Gson Serialize-Deserialize
dependencies {
implementation("com.github.developersancho.prefstore:prefstore-core:1.0.0")
}
data class Student(
val id: Int,
val name: String,
)
val pref = PrefStore(context = this, prefFileName = "prefFileName")
pref.write(key = "KEY", "default")
pref.read(key = "KEY", defaultValue = "")
val prefMoshi = MoshiPrefStore(context = this, prefFileName = "prefFileName_moshi")
prefMoshi.write(key = "KEY_MOSHI", "developersancho")
prefMoshi.read(key = "KEY_MOSHI", defaultValue = "")
prefMoshi.writeObject(key = "KEY_MOSHI_OBJECT", value = Student(id = 1, name = "moshi"))
prefMoshi.readObject<Student>(key = "KEY_MOSHI_OBJECT")
prefMoshi.readListObject<Student>(key = "KEY_MOSHI_LIST_OBJECT")
val prefGson = GsonPrefStore(context = this, prefFileName = "prefFileName_gson")
prefGson.write(key = "KEY_GSON", "gson")
prefGson.read(key = "KEY_GSON", defaultValue = "")
prefGson.writeObject(key = "KEY_GSON_OBJECT", value = Student(id = 1, name = "gson"))
prefGson.readObject<Student>(key = "KEY_GSON_OBJECT")
prefGson.readListObject<Student>(key = "KEY_GSON_LIST_OBJECT")
👤 Mr.Sanchez
- Github: @developersancho
- Email: developersanchez1903@gmail.com
Feel free to ping me 😉
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Open an issue first to discuss what you would like to change.
- Fork the Project
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a pull request
Please make sure to update tests as appropriate.
- Unit Testing
- Support more libraries
Copyright © 2021 - developersancho
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.