Hi
I am trying to do a simple shopping list- app. I had it almost complete but then I wanted to add a database to it and I connected it to firebase. So now I have these features set up and all good:
Create account
login
logout
save data to firebase
…
So now I want to get that data back to the app, but I have some issues understand how I should do.
So, before the database I hade the items showed through a DataViewerList. And I created a data source for that list which was updated as soon as I added or deleted something in my app.
So, with the database on, I guess I need to “update” the value on my data source file to the value saved in the database somehow? How can I do this?
Thanks Muneer for your reply!
Sorry for the lack of information.
The content of the green Value Block is copied from the value for the RealTime Databas “Get” function. So it should contain the Items of the userIDs stored at firebase. This is what I want to display in my DataViewerList later on.
The “row id”, I am actually a bit unsure in this… maybe this is the issue…? My attempt was to put this value in “any” row, as long as every unique value for every unique item goes in a row in that DataViewrList. that’s why I chosed “row id”.
For some clearance, this is how the app looks without the database (this is how I want it to display but with the saved value from the database instead.
That is another issue by itself. If you store “value” from the Firebase database in a single row in a table this the DVL (Data Viewer List) will show one single line.
You will need to loop through the entries obtained from Firebase and add them to the table row by row.
Why do you want to save the values in a table? Your answer would determine your approach to this app. If you don’t need the table for anything else other than display the food list then consider using the List Viewer instead because you would be able to directly assign the value block to the List Viewer.
If, in the other hand, you need to store the values in a table then you will need to do more coding blocks to manage all possible situations that could take place in your app such as the user viewing the results more than once or the user changes his mind and adds or removes food items from the list.
Thanks,
I am aware of the DVL show one single line-issue. I will need to format this some way…
I have been thinking about using a ListViewer as well but what made me choose the DVL was the ability to swipe-delete a row… As I have understood it that is not possible in a ListViewer?
…but maybe Ill go for the ListViewr anyway… If it’s that much issuer then, of course. I’ll just need to figure out som smooth way for the user to delete a row… Do you have any tips?
I guess this is how it could look like if I used a List Viewer instead? But for some reason the app crashes when doing so… Is there anything in here that seems obvious to you that I should be aware of…?
Thanks Muneer. I am trying to read the docs for “get object properties of”, I have never done anything similar so for me it’s kind of hard to get this in context. Could you give me some example how to use this? (with my text-box above as an reference would be awesome ;)), or if you could give me some link or place for good practice to learn handle these kind of things? It seem to be not that many video tutorials out there for these kind of things either…? Thanks for your help! I will now keep on reading and experimenting to see if I get any wiser today
The green block “value” has the data under “user” and therefore your “label1” should be connected directly to “value” without “get object” as this is not existing in the contents of “value”.
Most of the time Firebase will get you data in object form already and therefore you do not need to use “get object from JSON”.
Just add the block “generate JSON from object” before “value”. As I explained, Firebase returns data in object and you need to use one of the object blocks to read it.
Great, so this is right then? But then I am back to my original issue…how can I “format” this to display the second value (the word after “:”) only, so that it would look like this instead:
Albatross
Krax
Niklas
butter
cheese
corn
honey
milk
musli
soup ?