title: Fetching data from firebase database
body: <p>I want to fetch data from inside Firebase to check whether this user exists in database but there's a problem that i can't solve , listener trigger late this is my code :- </p>
  
  <ul>
  <li>if I remove while loop i can't fetch object fast</li>
  <li><p>if I keep while loop i enter infinite loop , i don't know why 
  why listener don't trigger </p>
  
  <pre><code>DataSnapshot fetched ;
  public boolean user_exist(final String user) throws Exception {
  users.addListenerForSingleValueEvent(new ValueEventListener() {
      @Override
      public void onDataChange(DataSnapshot dataSnapshot) {
          fetched = dataSnapshot ;
      }
      @Override
      public void onCancelled(DatabaseError databaseError) {
      }
  });
  while (fetched == null){
      Log.e("dbController","not fetched yet");
  }
  return fetched.hasChild(user);
  }
  </code></pre></li>
  </ul>