Firebase 查詢示例

private void loadData(){
        DatabaseReference dbRef = FirebaseDatabase.getInstance().getReference();

        Query dataQuery = dbRef.child("chat").orderByChild("id").equalTo("user1");
        dataQuery.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                if (dataSnapshot.exists()) {
                    // dataSnapshot is the "issue" node with all children with id 0
                    for (DataSnapshot issue : dataSnapshot.getChildren()) {
                        // do something with the individual "issues"
                    }
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }