Skip to content

Instantly share code, notes, and snippets.

@Suchiq
Created February 14, 2023 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suchiq/eaf30aba885fea5f4ffa78cb1b258042 to your computer and use it in GitHub Desktop.
Save Suchiq/eaf30aba885fea5f4ffa78cb1b258042 to your computer and use it in GitHub Desktop.
package com.example.featureflaglibrary
import android.content.Context
import android.content.SharedPreferences
class FeatureFlagManager : FeatureFlag {
lateinit var sharedPref: SharedPreferences
companion object {
const val feature = "feature"
}
fun init(context: Context) {
sharedPref = context?.getSharedPreferences(
feature, Context.MODE_PRIVATE
)!!
}
override fun setKeyValue(key: String, value: Boolean) {
sharedPref.edit().putBoolean(key, value).commit()
}
override fun getValue(key: String): Boolean {
return sharedPref.getBoolean(key, false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment