0

I have this structure in my Database inside the UserID I have this random ID which I declared when adding data to database I don't know how to call that to display the info inside to recycler view. Actually I can display the info in Recyclerview if the declared pushid is not there but I need that push ID to work on other modules. I am still learning so I get easily confused with this kind of thing. Any help would be so much appreciated.

database structure

This is the line which is calling the table.

mToolsDatabase = FirebaseDatabase.getInstance().getReference().child("toolHistory");

mToolsDatabase.child(list_user_id).child(mCurrentUser.getUid()).addValueEventListener(new ValueEventListener(){
public void onDataChange(DataSnapshot dataSnapshot) {
                    final String toolName = dataSnapshot.child("name").getValue().toString();
                    final String toolUser = dataSnapshot.child("user").getValue().toString();
                    final String toolBorrow = dataSnapshot.child("dateTimeBorrowed").getValue().toString();
                    final String toolReturn = dataSnapshot.child("dateTimeReturn").getValue().toString();
                    final String toolStatus = dataSnapshot.child("status").getValue().toString();
                    final String toolId = dataSnapshot.child("logId").getValue().toString();

                    viewHolder.setName(toolName);
                    viewHolder.setUser(toolUser);
                    viewHolder.setDateTimeBorrowed(toolBorrow);
                    viewHolder.setDateTimeReturn(toolReturn);
                    viewHolder.setStatus(toolStatus);
                    viewHolder.setLogId(toolId);

                }
Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
  • **[This](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is a recommended way in which you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo Nov 15 '18 at 10:05
  • In my case you see the child after the UID Hehe – Gabriel Apostol Nov 15 '18 at 12:19

1 Answers1

0

Firebase has its inbuilt method FirebaseRecyclerAdapter for display items in RecyclerView

Also, you can follow this link for more info

https://grokonez.com/android/firebase-realtime-database-display-list-of-data-firebaserecycleradapter-android-development