Skip to content
Permalink
Browse files

Introduce SharedPreferences into object graph

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
  • Loading branch information
msfjarvis committed Jan 14, 2020
1 parent f1604ad commit f1a60ffaf6f07f8654bde27fbd65bef08c248f4e
Showing with 9 additions and 0 deletions.
  1. +9 −0 app/src/main/java/dev/msfjarvis/daggertutorial/di/AppComponent.kt
@@ -1,16 +1,25 @@
package dev.msfjarvis.daggertutorial.di

import android.content.Context
import android.content.SharedPreferences
import androidx.preference.PreferenceManager
import dagger.Component
import dagger.Module
import dagger.Provides
import dagger.Reusable
import javax.inject.Singleton

@Singleton
@Component(modules = [AppModule::class])
interface AppComponent {

val preferences: SharedPreferences
}

@Module
object AppModule {

@Provides
@Reusable
fun provideSharedPrefs(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
}

0 comments on commit f1a60ff

Please sign in to comment.
You can’t perform that action at this time.