How can we save java list in android database. I try to save it using the setter method present in my model, but it does not work, and I get: "Each element of" value "must be a valid managed object" in the exception message.
public void storeNewsList(String categoryId, List<News> newsList) { Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); NewsList newsListObj = realm.createObject(NewsList.class); newsListObj.setNewsList(new RealmList<>(newsList.toArray(new News[newsList.size()]))); newsListObj.setCategoryId(categoryId); realm.commitTransaction(); realm.close(); }
Anil source share