Hi, I definitely have some difficulties to understand where to place a Csv file in order te read it after from the APP.
I red a very similar post :
' Reading Files from Internal Storage'
But at the end it doesn't work me.
Here is my goal : Copy a CSV files from my PC to My mobile with USB connexion, then open the Csv Files from the App with file component, read the data and write them to a firebase database with Firebase compent.
To make it simple, i built a new project with only this block :
I fixed the FileComponent to Share
I've copied a test file (ventes_syn2.csv) to the mobile
When I launch the App trough AICompanion, the app exit abruptly ! and the connexion is closed.
Then I tried to upload the files
Hi Gordon, if i set Defautlscope property to Asset, i got the message Error 2101, the file /download/ventes_syn2.csv could not be found... and i think it"s normal, Assets will look for the file in the app directory and mine is in the share directory in download subdirectory.
Hi, a strange thing to add, i tried to write instead to read with this block :
And it's run correctly, but it write 'essai' in the file in the share Download directory, but it has erased all the data of the csv file ?!
Loïc
Hi Gordon, the capitalization is correct in the block and on the storage. I've just made a mistake when i copied the error message (i've used lowercase letter)
Hi Gordon, for your info, i used another Defautscope : 'App', place the files in the directory: "PC\Redmi 9C NFC\Espace de stockage interne partagé\Android\data\edu.mit.appinventor.aicompanion3\files"
And the MIT App find now the files.
I still don"t understand what is going on, it's not where i want, but it's run, so... i will do with
Mny Thks anyway
Me too, I read the documentation and don't understand what the problem is.
App: Files will be read from and written to app-specific storage on Android 2.2 and higher. On earlier versions of Android, files will be written to legacy storage.
Asset: Files will be read from the app assets. It is an error to attempt to write to app assets as they are contained in read-only storage.
Cache: Files will be read from and written to the app’s cache directory. Cache is useful for temporary files that can be recreated as it allows the user to clear temporary files to get back storage space.
Legacy: Files will be read from and written to the file system using the App Inventor rules prior to release nb187. That is, file names starting with a single / will be read from and written to the root of the external storage directory, e.g., /sdcard/ . Legacy functionality will not work on Android 11 or later.
Private: Files will be read from and written to the app’s private directory. Use this scope to store information that shouldn’t be visible to other applications, such as file management apps.
Shared: Files will be read from and written to the device’s shared media directories, such as Pictures .
It is not possible to read a text file (non-media file) from the external storage (at least not on Android 11), that is not created by the app itself. To be able to read it from the shared storage / folders (/Download or /Documents) you need to save the text file there.
theoretically it would be possible using the Storage Access Framework...
however up to now we did not get any feedback from @ewpatton, if this feature is on the to do list of the MIT App Inventor team... this is a friendly reminder, so that this topic does not get forgotten...
see also
I don't know that the team has the bandwidth to implement such a feature right now, but I've filed it as a feature request on GitHub so potential open source contributors can take it on as a project.