AI2 cannot find or open a file

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.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Good idea. Here are the relevant blocks. If more blocks are useful, let me know.

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 (nb184, targetSdkVersion=29)?
  • Show all relevant blocks.

See also here:

1 Like

try a relative path or a full path
a relative path in your case starts with /RENPHO/
a full path starts with file:///storage/emulated/0/RENPHO/...

Taifun

1 Like

I tried all of these and they all failed:
file:///storage/emulated/0/RENPHO/Renpho-Steve Silberberg-data.csv
file:///storage/emulated/0/RENPHO/Renpho-Steve%20Silberberg-data.csv
/storage/emulated/0/RENPHO/Renpho-Steve Silberberg-data.csv
/storage/emulated/0/RENPHO/Renpho-Steve%20Silberberg-data.csv
storage/emulated/0/RENPHO/Renpho-Steve Silberberg-data.csv
storage/emulated/0/RENPHO/Renpho-Steve%20Silberberg-data.csv
/RENPHO/Renpho-Steve Silberberg-data.csv
RENPHO/Renpho-Steve%20Silberberg-data.csv
./RENPHO/Renpho-Steve Silberberg-data.csv

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):

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/...csv

On your device: → Internal Storage → Android → data → edu.mit.appinventor.aicompanion3 → files

and put these blocks in your app:

grafik

1 Like

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
Taifun

Try this:

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.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.