0

I have a model calss which i used to create groups

public class GroupModel {
    String groupId, groupName;
    ArrayList<GroupMember> groupMembersList;

    public GroupModel(String groupId, String groupName, ArrayList<GroupMember> groupMembersList) {
        this.groupId = groupId;
        this.groupName = groupName;
        this.groupMembersList = groupMembersList;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
}

when i store data using this model all the data stored except groupMembersList i don't know why. I uses following method to store group data

mdDatabaseReference
                .child(getResources().getString(R.string.group_list_child_key))
                .setValue(groupModel).addOnCompleteListener(task -> {//multiple informations in with same user(instertion will add new information)
            {
                if (task.isSuccessful()) {
                    Toast.makeText(this, "Group Created", Toast.LENGTH_SHORT).show();
                    Utils.hideProgress();
                } else {
                    Toast.makeText(this, task.getException().toString(), Toast.LENGTH_LONG).show();
                    Utils.hideProgress();
                }
            }
        });

where the groupModel is the object of above given GroupModel class.

Please suggest me as i am new to firebase.

1
  • Add GroupMember class Commented Dec 8, 2019 at 12:14

1 Answer 1

0

u dont have setter and getter for that arraylist ..refer this link - Getters and Setters for ArrayLists in Java

Sign up to request clarification or add additional context in comments.

1 Comment

does it matter to have setter and getter methods in model class as i uses constructor to initialize the groupModel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.