Why is it so difficult to save a CSV from a List?

As far as I can see, everything is ok with my blocks, so why can't I find where the CSV is being saved?

Most likely to do with your Android version.

Android 10 (API 29) and below require Write External Storage permission
Android 11 (API 30) and above do not require permission but can only save to a shared directory (/Documents or /Download [there is no Android directory called '/Downloads']) by using an extension - Anke's Mfile extension recommended. You will also need Anke's GetApi extension to take the correct action for the given Android version.

You should, technically, save to the Documents directory.

2 Likes

grafik

Thank you. My Android version is 12.
So do I just substitute Documents instead of Download(s) in the path?

I'm not having any luck following those directions. All I want to do is save a list outside of my app so that if I upgade the app, the master list is not lost. Am I going the wrong way to accomplish this?

Are you sure you read my guide? I do not think so.

If you want to stick with the File component and can accept that storage permissions are also requested on Android 11+, you have to

  • set DefaultFileScope = Legacy (in Designer)
  • use one of the two Shared folders /Download or /Documents.

Otherwise use my MFile extension which doesn't request / need storage permissions (READ / WRITE) on Android 11+.

@Mike_B
/Download without final S, /Downloads does not exist

It exists - at least on my Pixel 2 & 4XL.
(And you can access it using SAF.)

'/Downloads' is propriety isn't it? Or have Goggle added it to Android12 or replaced 'Download' in Android12?

Checked-out my phones:
Android 10: 'Download'
Android 12: 'Downloads'

That's a pita.

:cry: on my Samsung A13 Android 12 the file folder is Download, not Downloads. :astonished: This is true for both Internal storage and my external SD card.

:woman_shrugging:

My screenshot is from a test device with Android 12.

Android 10 (using default "Files" app)

Android 13 (using "AndExplorer")
(Although Files by Google shows "Downloads" == "Download")

so you have two file folders, Congratulations, on my Samsung A13 Android 12 the file folder is Download ,, there is no Downloads folder. Patel seems to have only a Download folder on his Android.

obviously not an Android 12, Samsung A13. What you get seems to depend on the flavor of your Android software and what the manufacturer of your device provides.

It appears whether your device (a Pixel) has Downloads/Download or only Download (my Samsung) depends on the phone manufacturer. :slight_smile:

grafik

As I said:

You cannot access non-media files that are not created by the app from the Shared folder /Download using SAF, but from /Downloads (which is NOT a Shared folder).

Maybe it's a google policy to discourage the use of shared folders

1 Like

There are a few possible reasons why you might be having difficulty saving a CSV file from a list in MIT App Inventor:

  1. Make sure you have the correct permissions to write to the storage location you're using. Depending on your device and Android version, you may need to request specific permissions to write to certain directories on your device.
  2. Make sure you're using the correct file path and filename. You'll need to specify the full path to the file you want to create, including the filename and extension (e.g. /storage/emulated/0/MyFile.csv).
  3. Make sure you're using the correct delimiter. CSV files use commas (,) to separate values, so make sure you're using commas in your list and not another character (e.g. ;).
  4. Check for errors. If you're having trouble saving the file, try using the File.AppendToFile block to append the CSV data to a file instead of overwriting it. This will allow you to see if there are any errors or issues with your code.

I hope this helps! Let me know if you have any other questions.