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
{
@Embedded
public Playlist playlist;
@Relation(
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: https://stackoverflow.com/questions/65044498/how-do-i-use-room-and-livedata-to-bind-to-a-foreign-key-relationship-so-i-can-fe
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.