I wanted to access the property of model by string via reflection like
Object o = ...; // The object you want to inspect
Class<?> c = o.getClass();
Field f = c.getDeclaredField("myColor");
f.setAccessible(true);
String valueOfMyColor = (String) f.get(o);
But i was still getting error that the property doesn't exist. Then i found that RealmModel objects are wrapped with RealmProxy class so that could be the reason.
So question is, how to access RealmModel properties by string? Via reflection or another way.
Aucun commentaire:
Enregistrer un commentaire