Realm-java: I can't save the object into realm

Created on 20 Jun 2017  路  3Comments  路  Source: realm/realm-java

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
image
I am sure it is not empty when i save it.

T-Help

Most helpful comment

hi, check this doc https://realm.io/docs/java/latest/#android-studio-debugging

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings