0

I need to access a variable that is inside the onSuccess method of a DocumentReference to outside query.

DocumentReference documentReference = fStore.collection("Users").document(fAuth.getUid());
    documentReference.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
        @Override
        public void onSuccess(DocumentSnapshot documentSnapshot) {
            final String admission = documentSnapshot.getString("Admission");
        }
    });

From the above code, I want to get the value of variable admission from outside of documentReference.

Query query = fStore.collection("studentAboutInfo").document("1234").collection("Leave");
    FirestoreRecyclerOptions<leaveStatusModalClass> options = new FirestoreRecyclerOptions.Builder<leaveStatusModalClass>()
            .setQuery(query, leaveStatusModalClass.class)
            .build();

I need the variables value to be used in the above query. Both are inside onCreate method.

Jerin Reji
  • 3
  • 1
  • 3
  • 1
    https://stackoverflow.com/questions/57330766/why-does-my-function-that-calls-an-api-return-an-empty-or-null-value – a_local_nobody Jan 27 '21 at 10:33
  • 1
    Is `documentSnapshot.getString("Admission")` returning the correct value? If yes, why don't you pass that value to a method that does the exact thing you want? – Alex Mamo Jan 27 '21 at 11:09

0 Answers0