我有此代码:
DocumentReference documentReference = fStore.collection("Studenti").document(userID);
documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
View header = navigationView.getHeaderView(0);
TextView text = header.findViewById(R.id.nume_elev);
//text.setText(documentSnapshot.getString("nume"));
//String mail = documentSnapshot.getString("email");
spec = documentSnapshot.getString("specializare"); // it gets the value from firebase
}
});
//Query
Query qexamene = fStore.collection("/Examene/an1/sem1").whereEqualTo("specializare", spec);
如何在onEvent方法之外使用“ spec”或“ documentSnapshot.getString”?