https://github.com/mancj/kpreference
Super lightweight Android preference Kotlin library made easy ⚙️⚙️⚙️
https://github.com/mancj/kpreference
android kotlin sharedpreferences sharedpreferences-editor
Last synced: 3 months ago
JSON representation
Super lightweight Android preference Kotlin library made easy ⚙️⚙️⚙️
- Host: GitHub
- URL: https://github.com/mancj/kpreference
- Owner: mancj
- Created: 2018-10-28T22:28:46.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-14T15:06:00.000Z (almost 7 years ago)
- Last Synced: 2025-09-08T13:54:30.805Z (4 months ago)
- Topics: android, kotlin, sharedpreferences, sharedpreferences-editor
- Language: Kotlin
- Homepage:
- Size: 91.8 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Edit SharedPreferences as easy as possible!💥🔥**
---
No need to interact with some **preference wrappers** or override a **setters**, simply declare
the **variables** right in your repository or other classes!!!
The only thing to do is to implement the `PreferenceHolder`
interface and override the `SharedPreferences`
```kotlin
class ServiceRepository @Inject constructor(
override val preferences: SharedPreferences /* override this */
) : PreferenceHolder { /* implement this interface */
// all preferences will be saved to the `preferences` object
val isFirstLaunch: Boolean by BooleanPreference(false) // false - default value
val userToken: String by StringPreference("default value")
//or even easier, without specifying the type
val someIntPreference by IntPreference(5)
}
```
Add library to your project.
```gradle
dependencies {
...
implementation "com.mancj:kpreference:$latestVersion"
}
```

# 🤩🤩🤩