feresr feresr - 4 months ago 68
Android Question

RealmObject AND Parcelable

I'm new to Realm for Android so I'm not sure I'm approaching this the right way. I have a class which looks like this:

public class Entry extends RealmObject implements Parcelable {

The problem is the
interface contains methods like
and RealmObjects aren't supposed to have methods other than getters and setters:

Error:(81, 17) error: Only getters and setters should be defined in model classes

So my question is: How can I make these two work together? Is there a better way than creating an separate class (maybe something like
)? Doing so would result in a lot of duplicated code...


Now there's a different workaround for that: just implement the RealmModel interface instead of extending from RealmObject:

public class User implements RealmModel {


You can find more information in the Realm Documentation.