Created
February 5, 2018 15:29
-
-
Save iamBedant/f3f7b03c7352bf5f0eb41cd0c242bcaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class ApplicationModule { | |
private final Application mApplication; | |
public ApplicationModule(Application app) { | |
mApplication = app; | |
} | |
@Provides | |
@ApplicationContext | |
Context provideContext() { | |
return mApplication; | |
} | |
@Provides | |
Application provideApplication() { | |
return mApplication; | |
} | |
@Provides | |
@DatabaseInfo | |
String provideDatabaseName() { | |
return "demo-dagger.db"; | |
} | |
@Provides | |
@DatabaseInfo | |
Integer provideDatabaseVersion() { | |
return 2; | |
} | |
@Provides | |
SharedPreferences provideSharedPrefs() { | |
return mApplication.getSharedPreferences("demo-prefs", Context.MODE_PRIVATE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment