Sunday, 28 February 2021

Workmanager with multiple roomdatabase

I'm creating a room database for each user log in which is singleton and trying to push data to server using WorkManager.

I'm able to save data to corresponding user database, but when i'm trying to fetch in my workmanager, db instance always points to first created db.

Is their a way to access particular db in workmanager?.

here is ApplicationComponent

    @Singleton
@Component(
    dependencies = [RoomComponent::class],
    modules = [
        ApplicationModule::class,
        AndroidInjectionModule::class,
        SubViewModelModule::class,
        LogRoomModule::class,
        WelcomeActivityModule::class]
)
interface ApplicationComponent {
    @Component.Builder
    interface Builder {
        @BindsInstance
        fun application(application: Application): Builder
        fun build(): ApplicationComponent
    }

    fun inject(application: Application)

  
    fun roomComponent():RoomComponent

}

and i'm injecting in application class

    daggerComponent = DaggerApplicationComponent.builder().application(this).build()
ApplicationInjector.init(this) { application ->
            daggerComponent?.inject(application)
        }

Any help is appreciated.

Thanks in advance.



from Workmanager with multiple roomdatabase

No comments:

Post a Comment