title: I can't get value outside the onDataSnapshot in Firebase
body: <p>What I'm trying to do is get the value outside of <code>OnDataSnapshot</code> but it always returns <code>null</code>. How do I access it from outside?
  It is always returning null because of being asynchronous.
  I have tried almost all the methods of Stack Overflow but none worked for me.
  Help me to get this value out of that function.
  Below is my code: I have declared String Outside</p>
  
  <pre><code>final DatabaseReference grpinfo = FirebaseDatabase.getInstance().getReference().child("Users").child(uid).child("Group");
      //listner not working properly
      grpinfo.addListenerForSingleValueEvent(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              group = dataSnapshot.getValue().toString();
              //cant get this value outside
  
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  
      //returns null in Toast
      Toast.makeText(getApplicationContext(),group,Toast.LENGTH_LONG).show();
  </code></pre>