Skip to content
Advertisement

Show data from Firebase in Recyclerview, filtered on username – How to?

With the following line of code I’m able to show the data under “results” of the User “Hendrik”.

JavaScript

But what I want, is to show the data under “results” according to which user is logged in. I think I’m supposed to work with FirebaseAuth to check which user is currently logged in? I’m not really sure tho, anyone has any suggestions?

Database tree

enter image description here

Inside my fragment

JavaScript

My adapter

JavaScript

Advertisement

Answer

I think I’m supposed to work with FirebaseAuth to check which user is currently logged in?

Yes. FirebaseAuth will generate unique ids for every user then you can structure your data like Users->uid-> then details

After that you could do this:

But what I want, is to show the data under “results” according to which user is logged in

by get uid of the current logged in user from FirebaseAuth and your database query will look like this:

JavaScript
Advertisement