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 :-
- if I remove while loop i can't fetch object fast
if I keep while loop i enter infinite loop , i don't know why why listener don't trigger
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); }