title: Randomly show firebase items
body: <p>I have different posts in my database</p>
  <p>This is the structure
  <a href="https://i.stack.imgur.com/S5iTJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5iTJ.png" alt="enter image description here" /></a></p>
  <p>What I am trying to do is show the posts randomly every time the user enters, I have seen different publications but I have not achieved my goal. If someone could guide me I would appreciate it very much</p>
  <p>This is how I get the elements from firebase, in the if it is to update some data.</p>
  <pre><code>segundoProyecto().addChildEventListener(new ChildEventListener() {
                  final Map&lt;String, LUsuario&gt; mapUsuarioTemporal= new HashMap&lt;&gt;();
  
                  @Override
                  public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
  
                      final model_inicio coment = snapshot.getValue(model_inicio.class);
                      final model_Linicio comentari = new model_Linicio(snapshot.getKey(),coment);
  
                      int posicion = adapter.addMensaje(comentari);
  
                      //condicion para no guardar 2 veces  a un mismo usuario
                      assert coment != null;
                      if (mapUsuarioTemporal.get(coment.getKeyEmisor()) != null)
                      {
                          comentari.setlUsuario(mapUsuarioTemporal.get(coment.getKeyEmisor()));
                          adapter.actualizarMensaje(posicion,comentari);
                      }else {
                          UsuarioKey.getInstancia().obtenerInformacionDeUsuarioPorLLave(coment.getKeyEmisor(), new UsuarioKey.IDevolverUsuario() {
                              @Override
                              public void devolverUsuario(LUsuario lUsuario) {
  
                                  mapUsuarioTemporal.put(coment.getKeyEmisor(), lUsuario);
                                  comentari.setlUsuario(lUsuario);
                                  adapter.actualizarMensaje(posicion,comentari);
                              }
                              @Override
                              public void devolverError(String error) {
                              }
                          });
                      }
                  }```
  
  
  
  I have tried to put a random in the updateMessage method, this works but not correctly since some Posts are repeated. Also try in the addMessage method to put the random and the same thing happens
  
     public void actualizarMensaje(int posicion,model_Linicio lComentarios){
          int pos = new Random().nextInt(model2.size());
          model2.set(pos,lComentarios);
          notifyItemChanged(posicion);
      }
  
      public int addMensaje(model_Linicio c){
          model2.add(c);
          notifyItemInserted(model2.size());
          return model2.size()-1;
      }
  </code></pre>