title: Recycler View showing only very last item added to realtime database
body: <p>I have a firebase strucuture as </p>
  
  <p><a href="https://i.stack.imgur.com/7ko9K.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ko9K.jpg" alt="database"></a></p>
  
  <p>The recycler view is only displaying the last added or say latest added node to the database instead of displaying each and every node </p>
  
  <p>the database reference i am using is </p>
  
  <pre class="lang-java prettyprint-override"><code>r2 = FirebaseDatabase.getInstance().getReference().child("Uploads").child("Wheat").child(S).child(D).child(T).child(FirebaseAuth.getInstance().getUid());
  </code></pre>
  
  <p>and the code for recycler view is as </p>
  
  <pre class="lang-java prettyprint-override"><code>public class MyPost extends AppCompatActivity {
  
      private RecyclerView recyclerView;
      private DatabaseReference r, r2, r3;
      private String S, D, T;
      FirebaseRecyclerAdapter&lt;RecyclerCropView, ViewHolder2&gt; Fbra1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_my_post);
          r = FirebaseDatabase.getInstance().getReference().child("User_Data").child(MainDashboard.type).child(FirebaseAuth.getInstance().getUid());
          recyclerView = (RecyclerView) findViewById(R.id.R_view2);
          r.addListenerForSingleValueEvent(rr);
      }
  
  
      private ValueEventListener rr = new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              S = dataSnapshot.child("State").getValue().toString();
              D = dataSnapshot.child("City").getValue().toString();
              T = dataSnapshot.child("Tehsil").getValue().toString();
              //   Toast.makeText(MyPost.this,S+D+T.toString(),Toast.LENGTH_LONG).show();
              r2 = FirebaseDatabase.getInstance().getReference().child("Uploads").child("Wheat").child(S).child(D).child(T).child(FirebaseAuth.getInstance().getUid());
              //   Toast.makeText(MyPost.this,r2.toString(),Toast.LENGTH_LONG).show();
  
              r2.addChildEventListener(new ChildEventListener() {
                  @Override
                  public void onChildAdded(DataSnapshot dataSnapshot, String s) {
  
                      r3=r2.child(dataSnapshot.getKey());
                      Toast.makeText(MyPost.this, r3.toString(), Toast.LENGTH_LONG).show();
                      FirebaseRecyclerOptions&lt;RecyclerCropView&gt; options = new FirebaseRecyclerOptions.Builder&lt;RecyclerCropView&gt;().setQuery(r3, RecyclerCropView.class).build();
                      Fbra1 = new FirebaseRecyclerAdapter&lt;RecyclerCropView, ViewHolder2&gt;(options) {
                          @Override
                          protected void onBindViewHolder(@NonNull ViewHolder2 holder, int position, @NonNull RecyclerCropView model) {
                              holder.setProductImage(model.getProduct_Image());
                              holder.setProduct(model.getProduct());
                              holder.setMax(model.getMaximumPrice());
                              holder.setQuantityUnit(model.getQuantityUnit());
                              holder.setQuantity(model.getQuantity());
                          }
  
                          @NonNull
                          @Override
                          public ViewHolder2 onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                              View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_post, parent, false);
                              return new ViewHolder2(v);
                          }
                      };
                      Fbra1.notifyDataSetChanged();
                      recyclerView.hasFixedSize();
                      recyclerView.setLayoutManager(new LinearLayoutManager(MyPost.this));
                      Fbra1.startListening();
                      recyclerView.setAdapter(Fbra1);
                  }
  
                  @Override
                  public void onChildChanged(DataSnapshot dataSnapshot, String s) {
  
                  }
  
                  @Override
                  public void onChildRemoved(DataSnapshot dataSnapshot) {
  
                  }
  
                  @Override
                  public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
                  }
  
                  @Override
                  public void onCancelled(DatabaseError databaseError) {
  
                  }
              });
  
          }
  
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      };
  
  
      @Override
      protected void onRestart() {
          super.onRestart();
          finish();
      }
  
  
  }
  </code></pre>
  
  <p><strong>Recycler view is only showing very last item that was added to database.</strong></p>
  
  <p><strong>Note:-</strong> </p>
  
  <ul>
  <li>The item.xml file has width set to wrap content.</li>
  <li>if i remove the childEventListener the recyclerView shows multiple items with 
  null on the place of TextView(These are those textView on which data retrived was supposed to be set)</li>
  </ul>