Kotlin: How can inflate Room data into a RecyclerView using Fragments?

Viewed 15

I trying use Room to inflate the Database in an RecyclerView, but all this using Fragments. I have the screen where the user enters the data and the screen where the RecyclerView is inflated, but I don't know how to make the Room data inflate in the RecyclerView and I still can't understand the viewModel.

1 Answers

For Getting data from Room this might get helpful and for view modal this helped me.

after getting data from Room you can simply notify the adapter.

example :

    var myList = ArrayList<YourModel>()
    roomDataList.forEach { item ->
//You can parse or convert your data according to your use
    myList.add(item)
    }
    adapter.updateList(myList)
Related