Created
April 26, 2021 08:04
-
-
Save varundwarkani/87b6e55b21cfdc11b23c9998bcbbc155 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 | |
@InstallIn(SingletonComponent.class) | |
public class RoomModule { | |
@Provides | |
@Singleton | |
public static AppDatabase provideDB(Application application) { | |
return Room.databaseBuilder(application, AppDatabase.class, AppDatabase.DATABASE_NAME) | |
.fallbackToDestructiveMigration() | |
.allowMainThreadQueries() | |
.build(); | |
} | |
@Provides | |
@Singleton | |
public static UserDataDAO provideUserDataDAO(AppDatabase appDatabase) { | |
return appDatabase.userDataDAO(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment