0

Let me explain with the help of a example. I have a Transaction Class (Realm table) which extends RealmObject. I want to create a DeletedTransaction Class (Realm table) which will store transactions after they are deleted. Instead of making two seperate Classes (Transaction and DeletedTransaction) which both extend RealmObject, can I just make the Transaction Class extend RealmObject and then can I make the DeletedTransaction Class extend the Transaction Class?

I know this is possible from the Java perspective, but I wanted to know from the Realm perspective. What are the pros/cons of such an approach?

arb93
  • 43
  • 10

1 Answers1

1

Inheritance in RealmObject is not supported. Issue#761

Instead of extending RealmObject, your classes can implement the RealmModel interface, adding the @RealmClass annotation:

@RealmClass
public class User implements RealmModel {

}

Reference-Docs

Aks4125
  • 4,522
  • 4
  • 32
  • 48