Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 811 Bytes

README.md

File metadata and controls

41 lines (35 loc) · 811 Bytes

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.