Hi everyone I need help with this part of my java code
public void getMydata() {
String B;
databaseAds= FirebaseDatabase.getInstance().getReference().child("AdmbAd");
databaseAds.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
String myBannerID = snapshot.child("bannerId").getValue().toString();
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
the question is how can modify this code to be able affect the value of myBannerID that I get from the server ( in onDataChange Method) to the String B located out of this method?