Permission issue in reading file from external storage

READ_EXTERNAL_STORAGE
WRITE_EXTERNAL_STORAGE

Thanks, then I can’t explain. You’re using Android 11? because I read so many things about changes in Android 11.

did you change and set this to your path ?

File f = new File("/storage/emulated/0/save/out.txt");

I`am using Android 10

This is the run

I had used the get path before and the path seems to be the same. I also manually created the “save” directory. Probably it has something to do with Android 11:

Maybe I have to try on another phone. But at the end I still want it to work on my phone.

which one worked with you ?

loadImage() works perfectly. As soon as I change it to load text file. I got either “path separator” or permission errors.

ok

try from APDE loadfile1 example as it is with out modify

see if it works or not

Got this from the above example with loadStrings()
java.lang.IllegalArgumentException: File /storage/emulated/0/twinkBOSS/env.txt/ contains a path separator

I was able to work around that by using Path or File etc. classes. But then it ended up with permission issue again :frowning:

this is not the path of loadfile1 example

the path is /storage/emulated/0/Sketchbook/LoadFile1/data/positions.txt

the path is /storage/emulated/0/Sketchbook/LoadFile1/data/positions.txt

Sorry, I can only see one example using positions.txt which is the one using loadStrings(). I don’t see an example with Sketchbook in the path.

Ok

Copy to sketchbook from the options then go to sketchbook folder

See if the loadfile1 folder created

I tried to do it on my phone (APDE). I put my sketch under the Sketchook folder where all other projects are and then I put my text file in my sketch folder. Then I use file name without path. It returns:

java.io.FileNotFoundException: /data/user/0/com.calsignlabs.apde.sketchpreview/files/env.txt

It’s looking in a very “secret” location when path is not specified. But I just can’t see the location on my phone.
I’m fine with any location. My goal is that user can locate the file and use a 3rd party editor to modify it or add new files to the location and my app can load them.
I could use dataPath() to specify the location. But that is also hidden for user :frowning:

my dear
can you please walk step by step

just answer this
have you use option move to sketchbook and got this sup folders

Looks like this issue is everywhere:

Some solutions work for some people and not for others.

have you use option move to sketchbook and got this sup folders



My app is very simple. It reads all text files from a single location. User should be able locate them and add, remove and edit.
My problem: I can read files (in development). But the location is “unknown” to user and therefore user have no access to the files.
Solutions:

  1. I define a location and set it in the app.
    But can’t read from specified location (permission error).
  2. I figure out the location system is using and tell the user.
    But users have no access to system defined location.

Sorry the link above was wrong, I fixed it:

I can use dataPath() and do everything under the sketch folder. But if the user installs the app via apk where is then his data directory.

ok friend

i am sorry i am asking something over and over and you keep answering something else my aim was to step with you to separate it is android 11 issue or not all examples i posted compiled and work

happy new year