Created
February 14, 2023 10:11
-
-
Save Suchiq/eaf30aba885fea5f4ffa78cb1b258042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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