'How to get data outside addonsuccesslistner in it in android Studio. My app is getting money if i put it in but while i put outside it shows empty [duplicate]

 .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
                    @Override
                    public void onSuccess(DocumentSnapshot documentSnapshot) {
                       MyVariable = documentSnapshot.get("money").toString();
                        textView1.setText(MyVariable);
                    }
                });

I want to take the Myvariable data outside of onSuccess, Please help please, I didn't find the Statisfied and Working idea in entrie Stackoverflow



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source