Challenge 2: A Module for Room — Solution @Module @InstallIn(SingletonComponent::class) object DatabaseModule { @Provides @Singleton fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase { return Room.databaseBuilder( context, AppDatabase::class.java, "app_database" ).build() } @Provides @Singleton fun provideTaskDao(database: AppDatabase): TaskDao { return database.taskDao() } } Notes: - @ApplicationContext context: Context is a special Hilt-provided qualifier that supplies the app's Application-level Context automatically — using the wrong kind of Context (e.g. an Activity Context) for building a database that should outlive any single screen would be a real bug, so Hilt provides this specifically-scoped one. - provideTaskDao(database: AppDatabase) takes the AppDatabase as a parameter, and Hilt automatically supplies it from provideAppDatabase above — the same dependency-chaining behavior shown in the chapter's NetworkModule (provideApiService taking a Retrofit parameter). - This replaces the entire manual companion-object singleton pattern from Chapter 3 (@Volatile var INSTANCE, synchronized block) — Hilt's own @Singleton annotation guarantees only one AppDatabase instance exists for the whole app, without writing that thread-safety logic by hand.