Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room Setup #6

Open
RivuChk opened this issue Jun 19, 2019 · 1 comment
Open

Room Setup #6

RivuChk opened this issue Jun 19, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RivuChk
Copy link
Collaborator

RivuChk commented Jun 19, 2019

So, I was trying to setup Room in this project.
I created the @Entity and @Dao classes inside the speakers module, as they should be used only inside that module.
Next, I created the AppDatabase class in the app module since it requires access to all Entity and Dao classes in all modules (for example @Database(entities = [SpeakerModel::class, SessionModel::class], version = 1))

The issue is, I couldn't figure out how to access AppDatabase from different modules. Access to AppDatabase is not really required, but if anyone can figure out a way to access instances of @Dao in respective modules, that'll be of much help.

Here's what I've done so far: https://github.com/adnan-SM/droidconChennaiV2/tree/roomsetup

@RivuChk RivuChk added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jun 19, 2019
@RivuChk RivuChk pinned this issue Jun 19, 2019
@AkshayChordiya
Copy link

It's a tricky problem to solve and there are multiple ways to solve it:

  1. Each module has it's own AppDatabase -> it's database file
    Pro: Super clean database layer
    Con: Relationship between entities in different module is not possible
  2. Create a db-module which has everything related to database and this module is implemented by all the features, this way they get access to AppDatabase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants