I am trying to fetch the data from the firebase database where the valueNum is the contact number with +91. I have shown the same in the screenshot attached but when I am running the code. It gave me a list of all the users even from different valueNum. However, If I pass the incorrect value, giving me the same result i.e. no error.database screen capture
private void funcDatabaseActivity(String valueNum) {
databaseReference.child("users").child("registered-user/" + valueNum).addChildEventListener
(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
if (dataSnapshot.exists()) {
UserData data = dataSnapshot.getValue(UserData.class);
Toast.makeText(ContactsActivity.this, "Data Exists - " + data.getDisplayName(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(ContactsActivity.this, "Data Not Exists", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
}
@Override
public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}