Java 如何在firebase数据库android中存储对象的arraylist
我有一个用于创建组的模型CalsJava 如何在firebase数据库android中存储对象的arraylist,java,android,firebase,firebase-realtime-database,Java,Android,Firebase,Firebase Realtime Database,我有一个用于创建组的模型Cals public class GroupModel { String groupId, groupName; ArrayList<GroupMember> groupMembersList; public GroupModel(String groupId, String groupName, ArrayList<GroupMember> groupMembersList) { this.groupI
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;
}
}
其中,groupModel是上述给定的groupModel类的对象
请推荐我,因为我是firebase的新手。你没有数组列表的setter和getter
…参考此链接-Add
GroupMember
classmodel类中是否有setter和getter方法,因为我使用构造函数初始化groupModel
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();
}
}
});