Home > Back-end >  data in reverse sort order in FirestoreRecyclerAdapter using StaggeredGridLayoutManager?
data in reverse sort order in FirestoreRecyclerAdapter using StaggeredGridLayoutManager?

Time:12-11

I am using Firebase as a backend for my notes making Android application and using "FirestoreRecyclerAdapter" for fetching the data from it. I want that data in reverse sorted order.

How can I achieve this using the FirestoreRecyclerAdapter?

database = FirebaseFirestore.getInstance();
reference = database.collection("users").document(currentUserId).collection("notes");
query = reference.orderBy("lastUpdated");

this query fetch data in sorted order in


StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, 1);

CodePudding user response:

Use Query.Direction.DESCENDING to sort in descending order in java;

query = reference.orderBy("lastUpdated",Query.Direction.DESCENDING);
  • Related