Can't open file for output on SD card

Started by om963, May 18, 2024, 13:48:23

Previous topic - Next topic

om963

When I try to open a file on the SD card for output, I get 'No such file or directory'. Opening for input works. I've given all the storage permissions I can find. Phone's own storage works in both directions.

om963

Why this came out black I don't know. Was not the intention  :-X

chrisws

Could you please share a small snippet of code to demonstrate the issue?
It should be possible to read a write files in SBs home folder.

om963

Ok, I see. So you can't open for output unless it's a home directory. I guess I've only used the home directory so far. How do you define a home directory? I guess that must have happened one way or another when I first downloaded SmallBasic, but I'm not sure how. I remember selecting SmallBasic to open .bas type files. Was that it?

I suppose it has not much significance but I'll attach the program where the 'problem' first surfaced. It indents a SmallBasic program. I noticed that when you use the phone for programming they'll start to go lopsided very easily. 

chrisws

You can obtain a few potentially different locations via environment variables:

path = env("EXTERNAL_DIR")
path = env("INTERNAL_DIR")

It's best to just use:

path = env("HOME_DIR")


om963

And I suppose you can't change them, not within the program anyway? I mean, I tried to change the HOME_DIR using env but no effect. 

chrisws

Sorry no. Google are pretty strict with what apps can access now. It seems reasonable for them to create this barrier for security.

om963

Hopefully safer that way, not just more restricted :) Thanks for the info!