How to get a randome value from firebase

How to get a random value from firebase
Every time opens the app get a random value and show it on a label
Example i add 10 datas every time i opens the the app get a randome value 1 to 10

Hi Anugrah,

You can retrieve all the data and use randomIntegerFrom in Math section.

Will you provide any block images i tryied but not getting the random datas

If I understood correctly,
you’d like a random entry from your database to be selected and displayed in a label every time the app is opened, right?

If that’s the case (and the database isn’t huge), you could download the whole thing as a list and use the random function from the Math section.

Hi Anugrah,

Let’s assume you have a database structured like this.

You can use these blocks to retrieve all the data and select a random one.

Let me know if I can be of any further help.

Its working. Thank you

1 Like