Display data list in order of date. Firebase

1

Hello, I have a firewall how to bring the data from the firebase and display in order by date, display from the most recent to the oldest, currently the data is being displayed in the default firebase.

database = ConfiguracaoFirebase.getDatabase().child("comentarios");
        //Listener para recuperar os comentarios
    valueEventListenerComentarios = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
                //Limpar lista
            listaComentarios.clear();
                //Listar comentários
            for (DataSnapshot dados: dataSnapshot.getChildren() ){
                Comentario comentario = dados.getValue( Comentario.class );
                listaComentarios.add( comentario );
            }
            arrayAdapter.notifyDataSetChanged();
        }
        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    };
    
asked by anonymous 15.05.2018 / 02:11

1 answer

1

After the child you put .orderByChild ("")

database = ConfiguracaoFirebase.getDatabase().child("comentarios").orderByChild("Referência_da_data_no_firebase");
    
15.05.2018 / 23:58