Dao is an object or interface that provides access to the database or other kinds of storage. So if we write network call in dao interface, is it still be ok or should we write another network call files to implement methods to do actions (such as fetch, post or delete ) to the server. As code, it works perfectly. But should we really do that, the network call method in dao interface?
Asked
Active
Viewed 265 times
4
-
1Do you mean annotations like '@'Entity, '@'PrimaryKey inside class Or actual methods? – Kirk_hehe Apr 02 '19 at 05:51
-
Yes. I mean in a class with the annotation of @Dao. (The Room Persistence one ) – MinnKhant Apr 03 '19 at 08:15
1 Answers
1
No, you should not write network call in Dao classes. Android architecture recommends you to create a separate repository(file/class) for network calls. Following link will help you better understand this architecture. Android Room with a View - Java

Afaq Ahmed Khan
- 2,164
- 2
- 29
- 39

Talha Arshad
- 133
- 1
- 10
-
Thanks, mate. But I had already done with the codelab you recommended. But I had seen some people's code in github and found out people wrote those their own style. Again, thanks a lot for you answer , mate. I am going to do that codelab one again. – MinnKhant Apr 03 '19 at 08:18