0

I am interested in representing folder system using RealmDB:

My first thought was:

 public class FolderItem extends RealmObject {
    public String name;
 }

 public class Folder extends FolderItem {
     public ArrayList<FolderItem> folderItems;
 }

 public  class File extends FolderItem {
    public String path;
 }

I am now seeing an error that Folder saying Annotated class Folder must extend a Realm class ... Does this mean recursive structures like this don't work or that inheritance is not fully supported? Or does anyone have better idea on how to do this?

1 Answers1

0

If folders only contain files and other folders, you could easily represent it without needing inheritance:

 public class File {
    public String name;
 }

 public class Folder {
     public String name;
     public ArrayList<File>   files;
     public ArrayList<Folder> folders;
 }
ast
  • 528
  • 2
  • 6