Skip to content

Instantly share code, notes, and snippets.

@sakshampruthi
Last active May 14, 2020 06:47
Show Gist options
  • Save sakshampruthi/20bf6f0091bacc79b196c3e11fca0dbf to your computer and use it in GitHub Desktop.
Save sakshampruthi/20bf6f0091bacc79b196c3e11fca0dbf to your computer and use it in GitHub Desktop.
object SaveSharedPrefernce {
const val CHECKTHEME = "checkTheme"
fun getSharedPreferences(ctx: Context?): SharedPreferences {
return PreferenceManager.getDefaultSharedPreferences(ctx)
}
fun setChecktheme(context: Context?, check: Int) {
val editor = getSharedPreferences(context).edit()
editor.putInt(CHECKTHEME, check)
editor.apply()
}
fun getChecktheme(context: Context?): Int {
return getSharedPreferences(context)
.getInt(CHECKTHEME, 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment