Skip to content

BoxResin/AndroidPreferenceUtil

Repository files navigation

Setup

  • build.gradle
buildscript {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/boxresin/maven/' } // Add this line.
    }
}

allprojects {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/boxresin/maven/' } // Add this line.
    }
}
  • app/build.gradle
dependencies {
    ...
    implementation 'boxresin.android:preference:0.2.0' // Add this line.
}

Usage

// Define a key.
val key = StringKey(keyName = "user_id", defaultValue = "none")

// Auto-casting as String, because 'key' is StringKey
val userId: String = Setting[key]

// Set value (only String type is allowed).
Setting[key] = "test"

// Error
Setting[key] = 1234

There are also StringKey, IntKey, LongKey, FloatKey, and BooleanKey.

About

SharedPreferences utility written in Kotlin

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages