I had see the docs and seems do it like the doc , but it don't work .
the Transaction commit success ,but when I search the db, it give me empty objects.
look the word:
ALog.e("MESSAGE", "getMessage" + list.size());
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
for (EMMessage message : list) {
HxMessageBean result = TUtil.EMMessage2HxMessage(message);
realm.copyToRealm(result);
}
realm.commitTransaction();
realm.close();
List<HxMessageBean> localList = realm.where(HxMessageBean.class).findAll();
ALog.e("TAG", "list.size():" + localList.size());
and
public static HxMessageBean EMMessage2HxMessage(EMMessage message) {
HxMessageBean bean = new HxMessageBean();
//......set the values
return bean;
}
when I search the db, I got it
I am sure it is not empty when i save it.
hi, check this doc https://realm.io/docs/java/latest/#android-studio-debugging
emmmm......
ok ... it is true.
but I suggest add the debug problem into the sample doc.
I had wasted 3 hour in this problem....
thank you.
Technically it is in the docs, but the following Google search would provide the right answer on Stack Overflow as well (for future reference)
https://www.google.com/search?q=realm+object+all+fields+are+null&oq=realm+object+all+fields+are+null
Most helpful comment
hi, check this doc https://realm.io/docs/java/latest/#android-studio-debugging