Skip to content

ionull/objectify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

objectify

KMP Object Preference Loader

Maven Central API

  • What's new in 3.1

    • Objectify now works both on Android and JVM project.
  • What's new in 3.0

    • Replace (migrate) shared preferences with datastore preferences.
  • Dependence:

     compile 'bz.tsung.kmp:objectify:3.1.3'
  • Usage:

    • Init

      // for android
      AndroidObjectify.init(
          context = context, 
          keysToMigrate = setOf(key1, key2), 
          migrateAll = false, 
          storeName = "awesome_app")
        
      // for jvm
      JvmObjectify.init(
          storePath = "/my/path/to/settings",
          storeName = "awesome_app")
    • Save

      ObjectPreferenceLoader(keyOfPreference, Model::class.java).set(model)
    • Load

      val model: Model = ObjectPreferenceLoader(keyOfPreference, Model::class.java).get()
    • List

      val models: ArrayList<Model> = ObjectPreferenceLoader(keyOfPreference, object : TypeToken<ArrayList<Model>>() {}.type).get()
    • Remove

      IntPreferenceLoader(keyOfPreference).remove()
  • Warning:

    PreferenceLoader.clear() method will remove all preferences!

  • Tips:

    In case u want to register type for gson, u can pass gson to constructor:

     ObjectPreferenceLoader(keyOfPreference, Model::class.java, gson)
  • Developer:

    Tsung Wu (@ionull) tsung.bz@gmail.com

About

KMP Object Preference Loader

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages