ActiveAndroid abstract class table ActiveAndroid abstract class table sqlite sqlite

ActiveAndroid abstract class table


Unfortunately ActiveAndroid does not support inheritance of models in that way just yet (https://github.com/pardom/ActiveAndroid/issues/14, https://github.com/pardom/ActiveAndroid/issues/257).

If you wanted to modify ActiveAndroid here's what you could do:

  • Create some kind of annotation that allows you define a model (Animals) as something that isn't persisted (refer to com.activeandroid.annotation.Table).
  • Upon trying to executing queries for that class you could use reflection to determine its child classes and then have it perform that query per child class.
  • Then you would basically take the list of results for each query and combine them into a single list and return that.

To be honest I've never seen inheritance in any Android ORM libraries, and personally I don't think it's a good design pattern for models. You may want to reconsider your reasoning for going down this path.