Paulina Szklarska
1 min readNov 28, 2017

--

Hi,

no, it’s not necessary, however it’a s good practice to have separate DAOs for different entities :)

If you’d like to have multiple DAOs, you need to create them seperately, e.g.:

@Dao
public interface UserDao {
...
}
@Dao
public interface RepoDao {
...
}
@Dao
public interface IssueDao {
...
}

And then you need to add them into your database class:

@Database(entities = { User.class, Repo.class, Issue.class }, version = 1)
public abstract class RepoDatabase extends RoomDatabase {

...

public abstract UserDao getUserDao();
public abstract RepoDao getRepoDao();

public abstract IssueDao getIssueDao();
}

And that’s it, you can use your DAOs now :)

--

--

Paulina Szklarska
Paulina Szklarska

Written by Paulina Szklarska

Flutter GDE / Flutter & Android Developer / blogger / speaker / cat owner / travel enthusiast

Responses (1)