// 1. Get a reference to SharedPreferences however you normally would. val prefs: SharedPreferences // 2. Use the extension functions to create a LiveData object of whatever type you need and observe the result. prefs.getBooleanLiveData("analytics_enabled", false).observe(this, { enabled -> if (enabled) { sendAnalytics() } })