In order to be able to get the data, you have to attach a listener on the Query object and iterate through the results as you can see in the following lines of code:
val rootRef = FirebaseDatabase.getInstance().reference
val ordersRef = rootRef.child("Orders")
val queryByTime = ordersRef.orderByChild("Time")
val valueEventListener = object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (ds in dataSnapshot.children) {
val phone = ds.child("Phone").getValue(String::class.java)
Log.d("TAG", phone)
}
}
override fun onCancelled(databaseError: DatabaseError) {
Log.d("TAG", databaseError.getMessage()) //Don't ignore potential errors!
}
}
queryByTime.addListenerForSingleValueEvent(valueEventListener)
Since your "Time" property is of type String, you may not get the best results, since the ordering is done lexicographically:
So the best option the you have is to change the type of the field from String to a number.