0

I am using Firebase as my database , I try to show at my RecyclerView the last entry on the top.

For now my data show from Old to New

This is the code that I Use, I try to use Collections.reverse


      

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      // Create a instance of the database and get
      // its reference
      mbase
          = FirebaseDatabase.getInstance().getReference();

      recyclerView = findViewById(R.id.recycler1);

      // To display the Recycler view linearly
      recyclerView.setLayoutManager(
          new LinearLayoutManager(this));

      // It is a class provide by the FirebaseUI to make a
      // query in the database to fetch appropriate data
      FirebaseRecyclerOptions<person> options
          = new FirebaseRecyclerOptions.Builder<person>()
                .setQuery(mbase, person.class)
                .build();
      // Connecting object of required Adapter class to
      // the Adapter class itself
      adapter = new personAdapter(options);
      // Connecting Adapter class with the Recycler view*/
      recyclerView.setAdapter(adapter);
  }

0 Answers0