how email's value change from "app-user/users"?

Firebase state : enter image description here

this isn't web language, i use javacode and xml of androidstudio.

i'm tryed under code.


I don't know what to do next.

1 Answers

Frank van Puffelen On Best Solutions

To get all users whose email address starts with user4:

DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference().child("app-users/users");
Query usersQuery = usersRef.orderByChild("email").startAt("user4").endAt("user4\uF7FF");

usersQuery.addListenerForSingleValueEvent(new ValueEventListener() {
    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot userSnapshot: dataSnapshot.getChildren()) {
            System.out.println(userSnapshot.getKey()+": "+userSnapshot.getChild("displayName").getValue(String.class));

    public void onCancelled(DatabaseError databaseError) {
        throw databaseError.toException();

To understand the usersRef.orderByChild("email").startAt("user4").endAt("user4\uF7FF") query, read it as:

  • Take all child nodes of usersRef and order them by their email property.
  • Then find the first child node that starts with user4.
  • Then return each child node, until you find a child that starts with .endAt("user4\uF7FF") (or further).

In this the \uF7FF is no magic code, but just the last known Unicode character. So by combining .startAt("user4").endAt("user4\uF7FF"), you're building a startsWith operator.