Convert LiveData to MutableLiveData

后端 未结 4 2043
天命终不由人
天命终不由人 2021-02-14 13:28

Apparently, Room is not able to handle MutableLiveData and we have to stick to LiveData as it returns the following error:

error: Not sure how to convert a Curso         


        
4条回答
  •  清酒与你
    2021-02-14 13:38

    In your repository you can get LiveData and transform it to MutableLivedata:

    var data= dao.getAsLiveData()
    return MutableLiveData(data.value)
    

提交回复
热议问题