Writing data in a .csv file not working

What is the android version of the device you are using?

Android 6,7,8,8,1,9,10,11,12 ?

I checked, it is a 12

I have compiled and tested my simple example on Android 12 and it works fine, creates the file and appends to it, so i am not sure why it does not work for you.

Are you trying to create the file Displacement_check_data.csv earlier in the blocks?


No, this is the first time it appears in this final block. I can put again the whole code : Last_Version_V5_with_ON_OFF_and_SAVING.aia (241.8 KB)

Then maybe it come from my manner to print values in the file which doesn't works

I see earlier in the topic you changed filescope to Legacy. filescope should be set to App in Screen1 designer and anywhere else in File component. No need to give/request read or write permissions if working on Android 12, in order to use the ASD.

Yes, as you say I changed Filscope to Legacy in Screen1 but also For my file component

Change filescope to App

You should not need either of those extensions.

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: