How Do I Call Sqlite Methods Through Viewmodel?
I searched everywhere but i didnt found any info or tutorial or blogs regarding sqlite with MVVM. how do i create viewmodel for my sqlite methods? i have tried various ways to acce
Solution 1:
The error just means that you are not submitting the compatible values :
In your code , when creating MutableLiveData , you have assigned it
ArrayList<HashMap<String,String>>
but when setting value to the MutableLiveData you are just passing a HashMap . So what you need to do is instead of passing HashMap directly ,you need to create an ArrayList and then to that arrayList you need to pass your HashMap and then set the ArrayList to the MutableLiveData .
You can do it somewhat like this .Below code is for illustration purpose
//Create an arrayList
ArrayList<HashMap> listofMaps = new ArrayList();
//then add all your hashmaps to your list
listofMaps.add(map);
//and then set it to the MutableLiveData
wordList.postValue(listOfMaps);
Or instead of the above process , the second way to solve this issue is , you just need to create the MutableLiveData of the Type : HashMap<String,String>
wordList = new MutableLiveData<HashMap<String,String>>();
Post a Comment for "How Do I Call Sqlite Methods Through Viewmodel?"