I ran into the problem of adding my model class to the Room database. I've read about @Relation, @Embedded, but I can not figure out what to do with my model class.
Here my model class which comes from the server. I need to store this data
public class ResultsItem {
private String model;
private int id;
private int distanceLon;
private String brand;
//*PROMBLEM HERE*
private List<BidsItem> bids;
//*PROMBLEM HERE*
private User user;
//*PROMBLEM HERE*
private List<FotosItem> fotos;
// getters/setters...
}
FotosItem class
public class FotosItem {
private String imageUrl;
private int resultItemId;
private int id;
//getters/setters
}
BidsItem class
public class BidsItem {
private double distanceToAuto;
private boolean isWin;
private int sum;
private String currency;
private int id;
//getters/setters
}
I will be very grateful if someone tells me what I need to do, or at least in what direction to move
LiveData<>for getting new data which was added to Room database. This data comes from server when paginate next portion of dataBidsItem,User, orFotosItemare. We do not know the nature of the relationship betweenResultsItemand these other things (e.g., does aUserhave oneResultsItemor N possibleResultIteminstances)? Most likely, all of these are entities, and you need to determine where the foreign keys go, based on the type of relationship you have. Ignore@Relation. At most,Usermight be@Embedded, if there is a pure 1:1 relationship betweenResultsItemandUser.BidsItemandFotosItemcode above