Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

kotlin-preferences-extensions

A set of Rx Extensions to get/set values of SharedPreferences in a super simple way

Usage

First add jitpack to your projects build.gradle file

repositories {
    maven { url 'https://jitpack.io' }
}

Then add the dependency in modules build.gradle file

dependencies {
    compile 'com.github.mirrajabi:kotlin-preferences-extensions:1.0.1'
}

Now initialize it in your application or activity etc...

override fun onCreate() {
        super.onCreate()
        KotlinPreferences.init(this)
        // Or with your custom preference name
        KotlinPreferences.init(this, "custom_pref")
    }

Then use these extensions on the key strings like below samples

Sample

companion object {
    val keyForString = "key_some_string"
}

keyForString.putString("Kotlin extensions")
            .subscribe()
            
"another_key".putBoolean(true)
             .subscribe({
                Log.v(packageName, "another key has been saved with $it value")
             })

keyForString.getString("No records for this key")
            .subscribe({ textView.text = it })
            
"another_key".getBoolean()
             .subscribe({
                Log.v(packageName, "Saved boolean value is $it")
             })

About

A set of RxJava2 Extensions to get/set values of SharedPreferences in a super simple way

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.