title: Static method to get DataSnapshot returns null
body: <p>I'm building an Android app that uses Firebase database and I need DataSnapshot a lot in the app so I decided to make a helper method to get me the DataSnapshot and here how I managed to implement it inside a Helper class that I created:</p>
  
  <pre><code>static FirebaseDatabase database = FirebaseDatabase.getInstance();
  static DatabaseReference playersReference =  database.getReference().child("players");
  static DataSnapshot snapshot;
  
  public static DataSnapshot getDataSnapshot(){
  
          ValueEventListener valueEventListener = new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  snapshot = dataSnapshot;
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
              }
          };
  
          playersReference.addListenerForSingleValueEvent(valueEventListener);
  
          return snapshot;
  
      }
  </code></pre>
  
  <p>But whenever I try to use the method it returns null, any help?</p>