【发布时间】:2021-08-09 08:13:18
【问题描述】:
我正在尝试从我的子集合数据中获取数据。
这是我的代码
database.collection("classes")
.document("classId")
.collection("subjects")
.document("subId")
.collection("materials")
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
materials.clear();
for (DocumentSnapshot snapshot:value.getDocuments()){
MatModel model = snapshot.toObject(MatModel.class);
model.setMatId(snapshot.getId());
materials.add(model);
}
adapter.notifyDataSetChanged();
}
});
请支持我使用Auto Id从材料中检索数据
这是我的firestore数据Screenshot 1和Screenshot 2的截图
【问题讨论】:
-
需要您的支持,请帮忙
-
您是否将
classId和subId存储在变量中?你能告诉我们你尝试了什么吗?请回复@AlexMamo -
@AlexMamo 先生,我可以在哪里与您分享完整代码?
-
不需要完整的代码,只需将这些 ID 保存在变量中的代码即可。
-
@AlexMamo 先生,我只在 SubjectModel.java 中存储了 subId
标签: java android google-cloud-firestore