如何在onEvent方法之外使用String变量?

时间:2020-07-05 21:22:58

标签: java android firebase google-cloud-firestore

我有此代码:

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”?

0 个答案:

没有答案