I have one small code i don't know how to do it.
I have Realtime database in firebase, and i want check if child name is exist or not.
example:
Realtime database:
i tried before this code and the compiler is pass from this code and not execute it or going to check.
mDatabase.child ( "Voted" ).child ( DataTeamVote.name.get ( position ) ).addListenerForSingleValueEvent ( new ValueEventListener ( )
{
@Override
public void onDataChange ( DataSnapshot snapshot )
{
if ( snapshot.hasChild ( mAuth.getCurrentUser ( ).getUid ( ) ) )
{
check = false;
Toast.makeText ( VoteAction.this , "You are already voted for this team" , Toast.LENGTH_SHORT ).show ( );
}
else
{
check = true;
Toast.makeText ( VoteAction.this , "Open Vote" , Toast.LENGTH_SHORT ).show ( );
}
}
@Override
public void onCancelled ( @NonNull DatabaseError databaseError )
{
}
} );