How do I use Room and LiveData to bind to a foreign key relationship so I can fetch a list by name and change its items?

I'm making a music player. So I have a table of Playlists with ID's and names, and a table of Tracks with names and playlist ID's. I made a class called PlaylistWithTracks like this:

public class PlaylistWithTracks
    public Playlist playlist;
            parentColumn = "id",
            entityColumn = "playlist_id"
    public List<Track> tracks;

My question is, if I have a DAO method that takes a playlist ID and returns a LiveData<PlaylistWithTracks>, how do I bind the tracks property to a RecyclerView? Do I have to take the PLaylistWithTracks object out of the LiveData thing and bind it to .tracks that way? I can't find any examples of this use case.

Read more here:

Content Attribution

This content was originally published by Matt Gregory at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: