android - Firebase firestore database returns null, the Query Snapshot value is empty but I have data stored on firestore, why is this returning null?
问题描述
here is the code I am using:
database.collection("final")
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
assert value != null;
Log.d("TAG", "onEvent: "+ value.isEmpty());
models.clear();
for (DocumentSnapshot snapshot : value.getDocuments()){
FirebaseModel model = snapshot.toObject(FirebaseModel.class);
assert model != null;
models.add(model);
}
adapter.notifyDataSetChanged();
}
});
public class FirebaseModel {
private String image;
private String title;
private String detail;
public FirebaseModel() {
}
public FirebaseModel(String image, String title, String detail) {
this.image = image;
this.title = title;
this.detail = detail;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
}
The value.getDocuments();
returns null but I have saved data on firestore database.
Log.d(TAG, "onEvent: "+ value.isEmpty());
this log returns onEvent: True which means it returns null not the data stored on firebase firestore
解决方案
推荐阅读
- rust - 如何为具有 AtomicUsize 字段的结构实现 Drop?
- python - Python Dask - 所有列的分组性能
- php - openssl_decrypt():为 AEAD 密码解密设置标签失败
- node.js - Google IOT:在 sendCommandtoDevice 失败后识别设备重新联机
- sql-server-2016 - bringing back a TDE database in AlwaysOn gives an error
- tesseract - Recognize the pdf type
- algorithm - 给定 n 个整数的列表,找到总和大于或等于 x 的最小基数子集
- java - Java中的时间计算问题
- reactjs - 即使数据未更改,传单集群标记也会重新呈现并关闭打开的蜘蛛
- r - “上次更新时间...”的日期在本地预览版和部署时不同