I want to retrieve data from Firebase
according to creation date and time
I haven't found any other method instead of creating a child of every user to save creation date and time sort by using orderByChild("Create")
but every user is saved with a random id how can I point to sort by the child of:
DatabaseReference userref = FirebaseDatabase.getInstance().getReference().child("Connection").child("Admin");
userref.orderByChild("Create");
userref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
Users users = userSnapshot.getValue(Users.class);
adminsList.add(users);
}
mAdapter = new Adapter_All_Admins(adminsList);
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
mRecyclerView.setAdapter(mAdapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});