Paulina Szklarska
1 min readNov 29, 2017

--

Ok, so creating only one DAO it’s just as simply as putting everything together in one class ;) So your DAO will look like this:

@Dao
public interface ModelDao {

@Insert
void insert(User user);

@Query("SELECT * FROM user")
List<User> getAllUsers();

@Insert
void insert(Repo user);

@Query("SELECT * FROM repo")
List<Repo> getAllReopsitories();
}

And your database class will have only this one DAO:

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

...

public abstract ModelDao getModelDao();
}

However, I still want to highlight that I don’t recommend this approach. Does it help you?

--

--

Paulina Szklarska
Paulina Szklarska

Written by Paulina Szklarska

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

No responses yet