Writing data in a .csv file not working

Hello Arthur

The file is being saved in the App's Private directory, so nobody can actually see it unless they have a security-breaking (often PC-based) program.

There is a lot of good info on the forum, but much of it concerning files and similar is not recent enough to cover the latest Google Android Security Measures - even the hint for the App Inventor Create File Block is unfortunately wrong.

Do you like the idea of cutting-out the middle man (TinyDb)? What is the CSV for - is it going to be distributed to others? If so, it will need to be saved in a Shared folder. If not, it's already being saved in the right place.

Ok I understand. What do you mean by "Do you like the idea of cutting-out the middle man (TinyDb)?" ?
The CSV is indeed intend to be distributed after (sharing it by mail for example, if this is what you asked)

What I mean is, my example does not store the data in TinyDb and then store the same data in a CSV file - it simply stores in the CSV file, making the complexity of store and restore from TinyDb redundant.

...then it needs to be saved in an Android Shared Folder. Unfortunately, for now we may have to ask for the Permission to write to a shared folder. (A mistake in the AI2 code).

...by the way, we notice you have in your code used 'legacy' scope. That is only for Android 10 and below.

A map by Power User Anke:

So you can see that the file should be saved in the Android folder 'Documents'. You will be able to see it there! App needs to be an APK though, Companion special cases file storage.

All right, isn't this extension (Error 908: The permission WRITE_EXTERNAL_STORAGE / bug) enought in that case ?

Yes about the Scop, I was going to respond to @TIMAI2 that I come back App's FileScope and indeed I have no more error messages

What extension is that?

An extension made by PowerUserAnke find on the same page where you probably got the map. It allow the App to get access to the phone storage if I understand well (but not sure to use it right)

As I previously indicated, with your current blocks, you do not require any extensions.

Yes ok I understand it by reading the map you show to me. Which class is considered my App : "Own app" or "Other app" in the shared Storage/Write block in the map ?

See my note in the post showing the directory map. :grin:

Your Own App is the App made by you, the files created by the App.

Setting it the Shared atleast works for me in Android 6.0.1

Please test it in your Android 12 device.

Demo.aia (67.3 YB) Ignore the size. Its just for fun. :joy:

Btw, the values in the TinyDB tags are preset to "How do you do ?" and "How are you ?", in the Screen1.Initialize event.

Hi Shubhamr69

Nice demo but:

  1. We do not need TinyDb if we are storing the data in a file
  2. The file should be stored in the Documents directory

.... also, the Demo does not use the 'Shared' permission as mentioned in your post :thinking:

Actually in that Demo aia, I make the code for every problem, then I clear the blocks. But i don't delete the components, as I might require them in another project later.

Wait what ?

Did I send a wrong .aia file ?

Wait, let me inspect.

Sorry, I had sent the wrong .aia file. I've changed it to the correct one.

1 Like

Is it working ? (The .aia)

No sorry, too complex to adapt to the bloks made by @ChrisWard and for which I would keep because I get a CSV in the perfect format. But thanks for the help

Could you please tell if the save file is working for you in my .aia ?

(The getText is not working though...)