I used a real-time database with this setting:
->users ->uid ->name ->email ->other info
If I wanted to save user data, I would use my User class and then set the object in the database as follows:
//assume variables have already been declared... mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser(); User user = new User(name, email, other values...); mDBRef.child("users").child(mFirebaseUser.getUid()).setValue(user);
I tried and it works great.
But how can I get these values ββfrom the database? For example, as soon as I set the User object as shown above, I can receive the user's email. I do not want to receive email through the input provider. I want to receive email through a database in real time. I tried to work this out for a while, but the documentation doesn't help much. All he shows is to set up listeners to wait for changes in the data. But I do not expect changes, I do not want a listener. I want to directly get the values ββin the database using the keys in the JSON tree. Is this possible with a real-time database? If so, how can this be done, because either the documentation does not explain it, or I just donβt understand it. If this is not possible, should I use the repository database or something else? Thanks.
android firebase firebase-database
David Velasquez
source share