Save CSV data / list as a file

@Anke, @Taifun: Thank you for all your support and Infos! I have taken a quick approach with the MFile extension. But quick approaches are never good. Unfortunately I didn't get it run. I had a look in the video and the blocks picture and thought that I understand what I have to do. But maybe I made a misstake or overlook something.

Unfortunately I can not spend more time at the moment. The weekend is over and I have to start programming for my job.

Now I have restored everything to standard file component. I'll give MFile another chance next weekend.

If not successful I'll build it in different way. I will request that the user (i.e. me) load the higscore at the beginning via the file picker (that's how it works). I use an indicator to determine whether the file has been loaded or not. Until that happens, I will simply not allow certain functions (e.g. deactivate the start button for the game)

Thanks again to you. I will be back as soon as i have new findings which might be interesting for others and leisure time

I use my own server, with my own security and encryption where necessary .

Need to go and find out what a Fritz box is :wink:

I would say it is in Germany the most common router for DSL / Internet / WLAN.

https://avm.de/produkte/fritzbox/fritzbox-7590/

Some of the devices (e.g. the one in the link) has a USB Port where you can plug in e.g. an externel HDD (in my case a SSD). The data which ist stored there can be accessed erverywhere in your local WLAN or also from Outside if you configure it. So it is one of a very simple kind of a NAS (network attached server).

I thought to buy something professional like from QNAP or Synology but for the moment it is too much for my needs.

Here are all the blocks you need (with a small correction):

Explain in more detail what role the FilePicker plays and show all relevant blocks.

After a long time I tried to continue with my app. It seams not to be a good day. In meanwile I read some more about the file scopes and i am more confused as before.Somewhere it was written that legacy ("Erbe" = compatibility mode) should not be used because it will disappear. For that reason I desided to use the build in File Component. But now I get the following error. I do not know what it means. Never got this error before.

Regarding the file picker: I do not need it. It is a workaround because when loading the file in screen.initialize the method file.gottext is not processed. If it still will not work automatically i will use a button to load the file. The file shall be created if it does not exist. So i do not need to pick up a file. The file for the highscore will always be the same for that app (hopefully).

Can you please give me a further hint what i am doing wrong? I hate that Android restrictions and the problems coming up with it when using file components in an own app which is created by the user itself.

Did you connect to Companion via USB?

See also here:

The File component needs (uses) a relative path (not a full or absolute).

"today" ist not "my day". Yes it was a misstake. I changed it after making the screenshot. but there is no difference. I do not understand where the join result comes from.

What you point out in the line from you ist new for me. I was happy to get it finally run with the AIStarter (and that many versions and different kinds of installations exists). When we wrote in march to that topic the problem did not occur. I will have a further look to my test/experimental project. maybe i find any difference...

if I do it like this the file is created...

image

save in the open procedure only for a quick test purpose

it seam to be a problem only in the file.exists function. is there a possibility to recognize the error when trying open the file when it is not existing e.g. in event screen.error and create the file initially in that case (in the way i tried it with file.exists) but without that function

grafik

file.exists function does not work for me. it looks good when i am insert it. but than after first run i get that error shown above. I did it now in that way ant it seems to work. when i delete the file on pc a new one is created. when i am insert dummy lines in the file (on pc) than the file is recognized by the app and it is not created again with initial content. what i can not explain is that now the file.got text event works even when file is loaded in screen.initialize event. i use now the app specific directory. as i can access it with file explorere on pc i think that it would be sufficient for my purpose. maybe i write a copy method to transfer it to documents directory (this should work because it worked already in the past)

i analyzed the error like this in screen.erroroccurred
image

now i implemented it as follows

event gottext is processed and the tableview extension is filled with correct values.
image

thanks for your help. i am not glad with my solution (in business job i would never check an error number or type directly) but i should learn that it is not always efficient trying to reach a 100% solution. i was very glad about that mit app stuff but this topic leads me to a point where thinking about to learn one programming language more and develop directly with android studio :wink: the complicated file handling still would persist but there are some effects can not explain. maybe there are synching problems or other stuff. it is miraculouse that some things does not work an when trying it some hours, days or weeks later suddenly seam to be working. of course there might be also some stupid bowl errors (Schusselfehler by google translation)

what you post in your last picture for your join result is clear. but in my case (see pictures above) the join delivers 2 different results while the content of the variables "pathRelative" and "fileHighScorer" are the same and have never been changed). join result in save is correct. join result in file.exist is wrong and i can not explain where the prefix "file:// comes from" not from the content of the variable but maybe from an internal buffer in ai2 which is not initialized and contains still a value from an old reference for example "pathAbsolut")

@Anke
Another question: is it possible to give the components own names e.g. "buttonLoadFile" instead of "Button17"? I could not find a solution but sometimes i see such things in screenshot (i think that i have seen it and hope that it was not an illusion)

The File.Exists method works fine. As long as you only work with Companion, there shouldn't be any problems with it. Once you run the same app as an APK, it stops working because the non-media file (.csv) was created by another app. In order for it to work with the APK, you must first delete the file with Companion.


I've pointed out the issue on Android 11+ for dozens of times here in the forum.

1 Like

yes and i have read it dozen of times. but i am still far away to build the apk file. i work at the moment only with the aiStarter and the connection via usb and mit app inventor in browser

As I said, there are problems with USB connection. Connect via WiFi.

this in fact is an aspect which i did not read that clear as you pointed out in your last post. but in fact i am new in that topic and it might be that i forgot that fact. connection via wifi is some kind of nerve killing for me with qr code and different things around (e.g. loss of connection and so on and the same procedure again and again).

there are a lot of things which someone have to learn or stumble over it as a newbe beside some errors, limitations or strange things that happen. for you as an expert some things/questions might be sound stupid or self-explenatory but for a beginner who can not know all the specific details or particularities it is another situation. But again: thank you for your help. I will continue reading in the forum to learn more and hopefully finishing my app to control my arduino project.

You can (and should) do this in the Designer.
Select a component and hit the Rename button.

1 Like

you are absolutely right. thank you a lot for pointing that out. i could not believe it what you wrote and i had another look to the designer. in fact i did not recognize that button although it is left of the delete button which i use permanently. that's embarrassing :slight_smile:

image