How to get a column in Firebase and display it in Listview?

Dear Thunk-friends,

I have a Firebase database in which I have the vocabulary I need to study (just as the picture). I want to concatenate the column “portuguese” and “alemão” and display the result in a ListView as “Guten Morgen - bom dia”, “Guten Tag - boa tarde”.

Capturar2

It’s not working. In a local database I did the same and it was working…

Any ideas?

Can you please show a mock up of what you want the result to show?

I think I know, however I can be very slow so I need more details :slight_smile:

Well, I was just preparing to answer you when I had an insight!

This code written above was to get some of my vocabulary from a firebase database and display it to me in a list view.

I expected to get:

Guten tag - bom dia
Gute Nacht - boa noite

But the only thing I was getting was an empty list or a list with one item. Remember yesterday in my previous post that I said I had to put a function WAIT…SENCONDS for some task to work? Prior to sending you this message, I tried it here and it worked.

Here would be a solution:

I might be wrong, but I feel that everytime you have a CALL FROM DATABASE statement inside a FOR EACH J statement, you MUST put this WAIT…SECONDS to get it to work.

It seems to be a problem from the platform. To debug this error I inserted a label on my screen to show in which variable J the app was to understand why my list wasn’t being built. I found that the app would crazily make a list of J’s without accomplishing the task inside the statement.

Another problem is that you cannot trust the results shown. For example: if you ask the app to WAIT 2 SECONDS between getting the results, you get wrong outputs. Take a look below.

If my code had another WAIT…SECONDS:

the outputs from the app would be repeated with one word refferring to more that one meaning:

When I remove the extra WAIT…SECONDS, what I get is


Note that the first word from the list will never appear and I got no idea why! Just accept and be happy! :rofl:

My conclusion is that you cannot trust it at all. Maybe what I will have to do is to make that WEB API you told me about yesterday. In fact I tried, but I still get no result and I have no clue about where my problem is.

Hi,

If you can export the database data to JSON format and send it to me, then I will look at the algorithm. I do not think that there is great difficulty.

The idea is simple. Need nodes 0,1,2 and so on. get as a list of objects. After that, you can display any data from this list of objects in the ListViewer.

Wow, thank you so much for trying to help me. I might have done a silly mistake there, but I cannot identify… As it doesn’t return anything, maybe it could also have a problem to connect to the json.

I made a blank app just to run tests. The link is https://x.thunkable.com/copy/24b02d9b9d14a0ad9b5bdab6c0464027

My json address is https://myvocab-30705.firebaseio.com/.json

Thank you once again!

I need to leave now, so I will show my example, which I did. If you do not understand, then in 3-4 hours I can make your example.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

Oh, thank you! I did mine similar to yours. It’s missing a purple statement that I don’t know what it is. Can you show me when you come back?

Sem%20t%C3%ADtulo

I log into the database using email and password, so the block is like that. Therefore, I added the SignIn block in order to quickly show my example. I think you don’t need this block here)

You are right, in my case I don’t need this block. In your app can you really display this list? In mine it doesn’t work…

If I put the key=“commands” (in my case “myvocab-30705”), the list is not displayed. Instead, if I put a number, requesting only one row, it really works.

Capturar

Capturar

If you could, would you take a look at this for me? The project is on Thunkable. It contains only one screen to make the tests easier.

Guys, I have an update. Based on what actech sent previously, I made some changes and it really worked for me.

Capturar

Some extra information:

  1. If I remove WAIT…SECONDS the app crashes;
  2. I use app response 1 (and 2) to get the info from the firebase, generanting a JSON object. The problem is that this object comes between " ". To remove these " I use the property get object from JSON. Now you ask me? Why didn’t you put everything together, in only one line?!?!?! Because it crashes!

Hope I could help anyone with my crash history. Now I’m like a headless chicken (and crashed!).

Thank you guys for all your support!

My blocks are 100% working, but they work for FireBase. Now I will make your blocks.

If you give me your ThunkableX app for FireBase project and Firebase Settings (API Key and Database URL)to it (in a personal message), then I will help you to make it work.

The difficulty is that you are a bit confused with how to specify the paths to nodes in the database, what is the list of objects. You have nodes 0, 1 … 42. You need to create a parent node and move all these nodes into it, as shown in my example.

In my example, the parent node “commands” and all nodes are in it.

I think this was my problem! I still don’t know how to use nodes. I was skimming through other examples and I realized that my json structure is a bit different from the ones people usually have. I am really making a confusion.

I made 2 different databases and they look just the same (except for the ID I added to the second):


Database 1: https://myvocab-30705.firebaseio.com/.json
Database 2: https://vocab2-2353a.firebaseio.com/.json

When I look at the JSON file, there I find the difference:
Database 1: {“0”:{“Alemao”:“Guten Morgen”,“Box”:0,“Data”:"",“Nivel”:“A1”,“Portugues”:“bom dia”,“aux”:""},…}

Database 2: [{“Alemao”:“Guten Morgen”,“Box”:0,“Data”:"",“Nivel”:“A1”,“Portugues”:“bom dia”,“aux”:"",“id”:1},…]

This is the confusion I am making. My JSON was originally written as DATABASE 1, and most of the examples I saw contain a JSON file like DATABASE 2.

Now I will tell

1 Like
  1. Create a “myvocab” node in the database with a value, for example, 1
  2. Open this node “myvocab” and import the file voc.txt (5.5 KB)
    into it. It should be such a structure
    %D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5
  3. Use block

1 Like

actech: I replicated your blocks but cannot get it to work. Can you take a look at the blocks and Firebase info below? Greatly appreciate any help.

To get the value of a field, you must correctly specify the path to this field. To do this, select a field and look at the path to it above the tree area, for example,

изображение

The path in my example is highlighted in a red frame

@gpo Try this:

The “cloud” variable will know to hit Firebase? Do I initialize “cloud?” Thanks

See attached screenshot. It seems I have it right? I am trying to pull all userNames into a list. How doI handle the UUID?