简体   繁体   中英

How to store arraylist of objects in firebase database android

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.

你没有那个arraylist的setter和getter..参考这个链接-Java 中ArrayList的Getter和Setter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM