How do I save data for different users using FirebaseDB?

Hello everybody!

I am a beginner in MIT APP Inventor, and I got a problem while creating my app. Using Firebase as Database I need to store data for each user, for example:
At the first screen we create an account and this information will be stored in users at the Authentication tab. Then with my account I can register my clients in a list, each client got their name, address,email, phone number. Now if a new user create a new account, when they hit their clients list button, it will show my clients instead of an empty list, and I don't want to share users information. I watched a buch of videos and tutorials trying to find a solution but still found nothing. I'm having difficult on creating this block. I know I still have to improve my logic, but if someone know how to deal that I would appreciate!

I think I understand what your saying. I have only used TinyDB but should work the same.

why not have it so that when a user creates an account they are given a number then when you store the information you add that number to the end of the tag. When it comes to displaying the clients you can set a display function that adds them to the list and removes the last digit of digits depending on the number. That way when you have multiple users when they select their client list you will run a search for the tag and you use the join function to join the client number to the end of your tag. now they can only see the information linked to their account. I hope that makes sense I am not great at explaining

1 Like

Firebase generates a UID (a unique identifier string) when a user authenticates with firebase. This is persistent for the user. You need to read and follow the firebase documentation. I would provide links, but you have not shown how you are using firebase with your blocks.....

1 Like

Thanks Man! I'll try to do that for sure!

1 Like

If you want examples blocks i have done something similar with TinyDb I can post the block here if you want ?

1 Like

I appreciate that! I think it would be helpfull!

This is the blocks to create new users.

So when a account is created you call something like this

then when it comes to creating the client list for each user you do something like

that way you go through all the information in the database to see if it contains the account number then when you add it to the list it removes the number from the name of the client.

PS is set to the account number or Ui in this case when the screen is initialized . Then each time a client is added just join PS to the end of the client name

its probably not the best solution but it works

1 Like

Thank you very much man! I'll build something like this!

You need to capture all your AuthUserData to a tinyDB tag before heading off to another screen.

Also, I suggest you have a good read of this about switching screens....

Use different screens wisely

If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while...      
The recommended method of switching screens in App Inventor
(Thanks Taifun)
Also see demo: multiscreen.aia

Thanks for help! I think there's much to learn about switching screens! I'll try to dry some screens from my app! hehe.. :smiley: