rosu alin rosu alin - 2 years ago 107
Android Question

How to save objects of external libraries in realm?

I know I need to extend RealmObject on all the objects that I have in realm, in order to create the database, but I use google maps and so I have a list of LatLng's in a object that I need to store in Realm.
The LatLng is a google maps class, so I do not have access to the .java file, so I cannot create a copy of that object that extends RealmObject.
Has anybody found a workaround this issue, is it possible?

Answer Source

Create your own class (e.g. MyLatLng) which mimics LatLng structure. Next create static method inside your MyLatLng class which converts MyLatLng object to LatLng object and vice versa. It have to be static because only setters and getters are allowed methods in RealmObject classes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download