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:
JavaScript
x
public class Entry extends RealmObject implements Parcelable {
}
The problem is the Parcelable
interface contains methods like describeContents()
writeToParcel()
and RealmObjects aren’t supposed to have methods other than getters and setters:
JavaScript
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 RealmEntry
)? Doing so would result in a lot of duplicated code…
Advertisement
Answer
Now there’s a different workaround for that: just implement the RealmModel
interface instead of extending from RealmObject
:
JavaScript
@RealmClass
public class User implements RealmModel {
}
You can find more information in the Realm Documentation.