Android room, List within entity?

Viewed 2814

I have the following Entity :

public class SubItem
{
    //....code
    Location loc;
}
@Entity(tableName = "Item_table")
public class Item
{
    @PrimaryKey(autoGenerate = true)
    public long id;
    public String Name;
    //...code
    List<SubItem> subItems;
}

the app consist of a RecyclerView that displays Items names only, and when a Item is pressed it should display the subItems in a different activity, so I only need to load all the information for each item except it's subItems, but in the same time I may need to be able to query the Items based on their subItems properties such as 'Location', What is the correct way to do that given that the given code does't work ? I think this answers why the code does't work, but I don't understand the proposed solution ?

1 Answers
Related