I have only found code snippets to load the currently logged in user:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
But what if I need to load another user's data, like the image path and name? I want to load them by their UID.
I could of course save the data myself like this:
-> users
-> UID
-> imagePath
-> name
But I thought there might be a way to use the FirebaserUser
class.
I actually think there has to be some way, it's just not written in the docs.
There's no way to do this directly using FirebaseUser
class. The old docs of Firebase 1.0
(Before it was acquired by Google) mentioned that exact scenario and the possible solution. The current doc is not completed yet.
The solution was to save the user's data in the Real-time database
keeping the uid
as the key. So when you need the data of another user, you'll just have to remember their UID
and can search for their data (Exactly like how you mentioned in the question description).
I searched the other way to do that without using Real-time database when I started working on my own app, however after finding no other method and reading the old doc, I gave up and used the database way. Trust me it's way easier and flexible to use the database, instead of hacking your way to avoid using it altogether.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With