Challenge 2: A Settings Repository with Hilt — Solution class SettingsRepository @Inject constructor( @ApplicationContext private val context: Context ) { val notificationsEnabled: Flow = context.dataStore.data .map { prefs -> prefs[PreferencesKeys.NOTIFICATIONS_ENABLED] ?: true } suspend fun setNotificationsEnabled(enabled: Boolean) { context.dataStore.edit { prefs -> prefs[PreferencesKeys.NOTIFICATIONS_ENABLED] = enabled } } } Notes: - @ApplicationContext private val context: Context is the same Hilt-provided qualifier used in Chapter 5's DatabaseModule — it guarantees this repository holds an app-scoped Context (which safely lives as long as the app does), not a shorter-lived Activity Context that could leak or become invalid. - Because SettingsRepository has an @Inject constructor and Hilt already knows how to provide a Context (via @ApplicationContext, built into Hilt itself), no separate @Module is needed for this repository at all — the same "you own this class, just annotate the constructor" rule from Chapter 5 applies here. - notificationsEnabled and setNotificationsEnabled wrap the raw DataStore calls from Challenge 1, exposing a clean, repository-level API — callers (a ViewModel, in Challenge 3) never touch PreferencesKeys or context.dataStore directly.