On the client side, ServerValue.TIMESTAMP is an object structured as follows: {.sv: "timestamp"}
So, as you know, you cannot easily do what you wanted. However, there may be another solution. If, for example, you need the last five entries, you can still set priority to ServerValue.TIMESTAMP :
mFirebaseref.child(userid).setPriority(ServerValue.TIMESTAMP);
And then use the limitToLast() method:
Query queryRef = mFirebaseref.limitToLast(5);
To get the last five entries.
It can also help: Display messages in descending order.
source share