Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.12 KB

README.md

File metadata and controls

40 lines (29 loc) · 1.12 KB

Download Kotlin badge badge

kotlin-multiplatform-mobile

SharedPreference in Kotlin Multiplatform Mobile (KMM)

This is a Kotlin MultiPlatform library that provides access to the shared preferences on iOS & Android.

setup

kotlin {
  sourceSets {
    val commonMain by getting {
      dependencies {
        implementation("de.gal-digital:kmm-preferences:x.x.x")
      }
    }
  }
}

usage

class Settings(sharedPreferences : SharedPreferences) {

  private val jsonSerializer = Json {}

  var token : String? by preference(sharedPreferences, "token", null)

  var user : SomeSerializable? by serializable(sharedPreferences,jsonSerializer,"user", null)
}