0

I am having an activity in which there is a button get uid, I am registering users and it is creating unique id for each user in Firebase database. What I want is when i click the button it will choose the Uid from the available Uids in firebase database and show that id , but the ids must be random and it must be from the database of users who register themselves in the app. How to get random UId everytime?

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Do you want to fetch the UID that Firebase generates for that particular user? – Saurabh Thorat Aug 06 '17 at 14:15
  • Yes ..bt i want to fetch random uid everytime , like the pointer goes through each id and give me random uid everytime like shuffling – ShUbHaM raWat Aug 06 '17 at 14:20
  • i want to make chat app to connect randomly using uids , is there any better way to do it ? – ShUbHaM raWat Aug 06 '17 at 14:37
  • Firebase has a codelab to make a chat app here: https://codelabs.developers.google.com/codelabs/firebase-android/#0 – Saurabh Thorat Aug 06 '17 at 14:40
  • See https://stackoverflow.com/questions/40853157/firebase-random-query/40853780#40853780, https://stackoverflow.com/questions/40765613/get-random-child-from-firebase-database, https://stackoverflow.com/questions/43035087/how-does-one-get-a-random-children-of-a-firebase-node and more from this list: https://stackoverflow.com/search?q=%5Bfirebase%5D+random+child – Frank van Puffelen Aug 06 '17 at 15:14
  • You can store the userID in an array and choose them randomly. If you want to pursue with that path. I can show you. – UmarZaii Aug 06 '17 at 16:10
  • But then the userid will act as local how can i implement it in global level..means i store the id in type of global storage so that i cam access it when i want to connect – ShUbHaM raWat Aug 06 '17 at 16:15
  • Go checkout my post [here](https://stackoverflow.com/questions/49038712/how-do-i-retrieve-a-random-object-from-firebase-using-a-sequential-id/53330758#53330758). I think it is exactly what you are looking for! let me know if it helps – A. Welch Nov 16 '18 at 03:06

1 Answers1

1

I don't think it is possible . Since Firebase will return a UID that is associated with a particular user.

I read the docs getIDToken

Unless you have stored the passwords & emails of all the users who registered, then you can request the UID one by one and store them in an array.Then you can do a Random function based of the length of the array.

Pc hobbit
  • 96
  • 1
  • 11