0

i need a little help. I got the following two classes and if i want to push an Object with the the code below, it only pushes the object variables from the Super Class(Group). So i get these Data:

enter image description here

How can i push the other variables too ?

PrivateGroup pg = new PrivateGroup(username,groupName,description,state,city, password);
pg.getMembers().add(username);
reference.child("groups").child("private").push().setValue(pg);

Group.class

@IgnoreExtraProperties
public class Group implements Serializable {

    private String owner;
    private String name;
    private String description;
    private List<String> members;

    public Group() {
    }

    public Group(String owner, String name, String description) {
        this.owner = owner;
        this.name = name;
        this.description = description;
        this.members = new ArrayList<String>();
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<String> getMembers() {
        return members;
    }

    public void setMembers(List<String> members) {
        this.members = members;
    }

    @Override
    public String toString() {
        return " Group{" +
                "owner='" + owner + '\'' +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", members='" + members + '\'' +
                '}';
    }
}

And PrivateGroup.class

@IgnoreExtraProperties
public class PrivateGroup extends Group implements Serializable {

    private String state;
    private String city;
    private String password;

    public PrivateGroup() {

    }

    public PrivateGroup(String owner, String name, String description, String state, String city, String password) {
        super(owner,name, description);
        this.state = state;
        this.city = city;
        this.password = password;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "PrivateGroup{" +
                "owner='" + this.getOwner() + '\'' +
                ", name='" + this.getName() + '\'' +
                ", description='" + this.getDescription() + '\'' +
                ", state='" + state + '\'' +
                ", city='" + city + '\'' +
                ", password='" + password + '\'' +
                ", members='" + this.getMembers() + '\'' +
                '}';
    }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Flo June
  • 13
  • 3
  • Handling of subclasses is still missing from our SDK, will be added in a future version. See http://stackoverflow.com/questions/37547399/how-to-deserialise-a-subclass-in-firebase-using-getvaluesubclass-class for more and a workaround – Frank van Puffelen Jul 06 '16 at 14:58
  • thx for your answer ;) – Flo June Jul 06 '16 at 15:25

0 Answers0