My AI2 app cannot seem to locate a file on my Android that the file manager says is there. Look at these 2 screen shots. Am I missing something fundamental about storage? Will spaces in the file name cause problems (the app that creates the csv inserts them into file names). Any insight appreciated.
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.
The space between first name and last name can't be helping. Add a hyphen to the filename and in your text block between the two list selections.
Also, when in companion, run a Do It on your join block to check the filename to be read matches the actual filename
Since I may not be able to change the file name that the Renpho app generates, can the ReadFrom block accept wildcards?
Pretty certain the answer is no.
- Where does the file (
...-data.csv) come from (was it created by the app)?
- Companion or compiled app (APK)?
- Were permissions (WRITE / READ) requested / granted?
- Which Android version?
- Did the app work before the AI2 update (
- Show all relevant blocks.
See also here:
try a relative path or a full path
a relative path in your case starts with
a full path starts with
I tried all of these and they all failed:
How about answering my questions.
- The CSV file is created by an export of a 3rd party app called Renpho
- I am using the companion (I think). I have not compiled it to an .apk
- No permissions were requested or granted. My file manager app says it's readable, writable and not hidden.
- Android version 10
- Reading files has never worked for me. This is new code I've been developing.
- I'm not sure what other blocks are relevant besides the ones I already posted.
Thank you for any help.
How do I do this? Googling "do it" doesn't show any relevant documentation.
When you have your project running in companion mode, right click on the block, you will get the Do It option in the sublist. Select this and it should show the output for the block. A useful debugging tool.
OMG this is amazing!!! Thank you very much!
This didn't fix my file reading problem, but it is a great tool.
Did you read this? Problem with July 30 2020 Version: nb184 no longer able to write and read files - #15 by Anke
... and please read the complete thread.
Do you have another test device with Android < 10?
Try this for your Android 10 device:
Copy / move the csv file to the ASD (app-specific directory):
On your device: → Internal Storage → Android → data → edu.mit.appinventor.aicompanion3 → files
and put these blocks in your app:
Yes, that works!!!!
But since this is something I will have to do repeatedly, is there a way to have App Inventor 2 move or copy the CSV to the app specific directory?
the file extension is able to copy files, also to the ASD
there also is a method ApplicationSpecificDirectory available there
For me it works on a Pixel 2xl Android 11 (Companion). We all have to learn again since the update (nb184). So tell us if it works on your device (Android 10). And test it with the compiled app (APK) too.
I am very much looking forward to trying this out, but I am going camping all this week and won't be able to try it until the end of the month. thank you for all your help.