(Android studio) How to get a user id from their email in Realtime Database (Firebase)

Asked

Viewed 297 times

-1

I would like to know how I can get an id of my database in firebase by email.

For example I have the email [email protected] and would like to get his id just by email. It is possible?

  • Hello Hiago, your question is vague, try to exemplify. Because for example if Voce add a user in firebase it is automatically updated and is updated in all db’s of users. So it depends on which business rule of your app, the user will log in with the email, name, phone, Voce user who decides.

  • Hello, so I have organized my database like { "user" { "Mtizqgdtywlslmnvbq==": { "email" : "[email protected]", "id" : "Mtizqgdtywlslmnvbq==", "age" : "15", "name" ": "Henrique", }, "aG1lbmRvbmNhcm9kcmlndWVzQGdtYWlsLmNvbQ==": { "email" "[email protected]", "id" : "aG1lbmRvbmNhcm9kcmlndWVzQGdtYWlsLmNvbQ==", "age" : "20", "name" ": "Henrique", }, How would I know which email has [email protected] and get his id.

1 answer

-1

In this case Thiago, Voce can use firebase Authentication with some platform like facebook and google not to need password, or can include the password key in your db.

To make a "search" in your db it must be ordered, firebase already gives you all these implementations, both "search" and "order", in the firebase page itself gives you the necessary examples to solve your problem, follow the link. I hope I’ve helped.

  • I’m sorry, but I couldn’t find anything there that could help me :(

  • post your code on which you make the request pro db

  • Unfortunately all I have is to pick up a value by id, but I would like to know how I can pick up an id just by email, because I have a login screen where I wanted to pick up the email that the person logged in and so display some information about it. I’ve tried it with the id giving a getId but it’s showing an id that isn’t from the user, so I wanted to kind of take a turn to display the data from it

  • Got it, in case Voce has to do a query for your db and search for his Child, has the function equalTo() that Voce looks for the exact value. Unfortunately the theme is very wide, but I will try to guide you through the references, https://firebase.google.com/docs/reference/js/firebase.database.Query#equalThis is about the function with example, but this link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data Voce will find more answers is only about the sort and query of db

  • Okay, thanks I’ll try that.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.