morristech
3/9/2019 - 5:03 PM

AppModule.java

@Module public class AppModule {

  private Application application;

  public AppModule(Application application) {
    this.application = application;
  }

  @Provides @Singleton Context providesAppContext() {
    return application.getApplicationContext();
  }

  @Provides @Singleton AppDatabase providesDatabase(Context context) {
    return Room.inMemoryDatabaseBuilder(context, AppDatabase.class).build();
  }
}