什么是空指针异常(java.lang.NullPointerException)以及它们的原因是什么?
可以使用哪些方法/工具来确定原因,以便停止异常导致程序过早终止?
在这里,我需要拥有多个品牌,每个品牌下还有多个子品牌.我之前尝试使用'地图',但它确实非常混乱,并且还了解到拥有多个文档会更好.我对此非常陌生,现在已经挣扎了3-4天.任何帮助将非常感激.
firebaseFirestore.collection("Coffee").addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
if (e != null) {
Log.d(TAB, "Error : " + e.getMessage());
}
for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
if (doc.getType() == DocumentChange.Type.ADDED) {
Log.d("Brand Name: ",doc.getDocument().getId());
// how to retrieve documents of subCollection here? something like doc.getDocument().collection??
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢.