Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Created September 8, 2020 15:36
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 StephenVinouze/a5bf0ea99fb7e1980ff09af86c3fa4c0 to your computer and use it in GitHub Desktop.
Save StephenVinouze/a5bf0ea99fb7e1980ff09af86c3fa4c0 to your computer and use it in GitHub Desktop.
class UpdatePreferences @Inject constructor(context: Context) {
companion object {
private const val UPDATE_DETECTOR_SHARED_PREFERENCES = "updateDetector"
private const val VERSION = "updateDetector:version"
}
private val sharedPreferences: SharedPreferences by lazy { context.getSharedPreferences(UPDATE_DETECTOR_SHARED_PREFERENCES, Activity.MODE_PRIVATE) }
var version: String?
get() = sharedPreferences.getString(VERSION, null)
set(value) {
value?.let { sharedPreferences.putString(VERSION, it) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment