I've searched a lot on internet but i could not find the exact answer i need.
After implementing this method to get data from firestore from a specific document where username="dotcom"
public void UserData(){
db.setFirestoreSettings(settings);
CollectionReference peopleRef = db.collection("member");
peopleRef.whereEqualTo("Username", "dotcom")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
DocumentSnapshot document;
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
Log.d("TAG", document.getId() + " => " + document.getData());
}
} else {
Log.d("TAG", "Error getting documents: ", task.getException());
}
}
});
}
i need the value of document.getData() to use it in another method inside the same class. I've tested local and global variables with setters and getters, it won't work for me :(