Skip to content

Instantly share code, notes, and snippets.

@janishar
Created December 25, 2016 07:47
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 janishar/0d3466801f069a70def4ea11a3812331 to your computer and use it in GitHub Desktop.
Save janishar/0d3466801f069a70def4ea11a3812331 to your computer and use it in GitHub Desktop.
@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