# Permission issue in reading file from external storage

**URL:** <https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184>\
**Category:** Processing for Android\
**Created:** [December 18, 2021, 1:13pm UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184 "2021-12-18T13:13:46Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 1:45am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/21 "2022-01-01T01:45:27Z")

</div>

READ\_EXTERNAL\_STORAGE  
WRITE\_EXTERNAL\_STORAGE

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 1:47am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/22 "2022-01-01T01:47:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 1:52am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/23 "2022-01-01T01:52:16Z")

</div>

did you change and set this to your path ?

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

```

I`am using Android 10

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 1:56am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/24 "2022-01-01T01:56:40Z")

</div>

This is the run

 ![Screenshot_2022-01-01-03-53-18-689](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2e8146d6bf982aa60e47806ffef55d4198687c1e.jpeg)

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 1:59am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/25 "2022-01-01T01:59:46Z")

</div>

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:

> <https://stackoverflow.com/questions/66557956/creating-a-csv-file-in-android-11-return-error-java-io-filenotfoundexception-e>

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

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 2:04am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/26 "2022-01-01T02:04:03Z")

</div>

> [@bigboss97](#):
>
> @jafal Just tested above code. That works. Thanks so much. I’ll work on that.

which one worked with you ?

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 2:08am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/27 "2022-01-01T02:08:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 2:14am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/28 "2022-01-01T02:14:49Z")

</div>

ok

try from APDE loadfile1 example as it is with out modify

see if it works or not

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 2:22am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/29 "2022-01-01T02:22:41Z")

</div>

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 ☹

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 2:35am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/30 "2022-01-01T02:35:14Z")

</div>

> [@bigboss97](#):
>
> File /storage/emulated/0/twinkBOSS/env.txt/ c

this is not the path of loadfile1 example

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

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 3:08am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/31 "2022-01-01T03:08:02Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 3:21am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/32 "2022-01-01T03:21:55Z")

</div>

Ok

Copy to sketchbook from the options then go to sketchbook folder

See if the loadfile1 folder created

 ![Screenshot_2022-01-01-05-14-11-865](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/bbbf7c5b6c6049de852217730579573df7b65bdc.jpeg)

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 3:53am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/33 "2022-01-01T03:53:34Z")

</div>

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:

```auto
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 ☹

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 4:05am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/34 "2022-01-01T04:05:29Z")

</div>

my dear  
can you please walk step by step

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

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 4:08am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/35 "2022-01-01T04:08:43Z")

</div>

Looks like this issue is everywhere:

> **[How to Fix Exception 'open failed: EACCES (Permission denied)' on Android -...](https://trendoceans.com/how-to-fix-exception-open-failed-eacces-permission-denied-on-android/)**
>
> It is very simple to resolve Exception 'open failed: EACCES (Permission denied)' Go to the project pane and Click on AndroidManifest and add the highlighted code inside .

Some solutions work for some people and not for others.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 4:10am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/36 "2022-01-01T04:10:38Z")

</div>

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

 ![Screenshot_2022-01-01-05-58-45-042](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b7fa3e9de28a8258c09180364711453f35359355.jpeg)  
 ![Screenshot_2022-01-01-05-59-30-669](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/795caf890a0538dc5e56ad8bfe6a8e26600d23fa.jpeg)  
 ![Screenshot_2022-01-01-05-59-47-700](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a988b97b822afc6538a335b1831e180656a4eaf2.jpeg)

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 4:18am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/37 "2022-01-01T04:18:14Z")

</div>

> [@jafal](#):
>
> can you please walk step by step

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.

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 4:21am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/38 "2022-01-01T04:21:47Z")

</div>

Sorry the link above was wrong, I fixed it:

> [@Permission issue in reading file from external storage](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/35):
>
> Looks like this issue is everywhere: Some solutions work for some people and not for others.

---

<div class="post-metadata">

**Author:** ![bigboss97](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@bigboss97](https://discourse.processing.org/u/bigboss97)\
**Post date:** [January 1, 2022, 4:26am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/39 "2022-01-01T04:26:24Z")

</div>

> [@jafal](#):
>
> have you use option move to sketchbook and got this sup folders

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.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 1, 2022, 4:36am UTC](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184/40 "2022-01-01T04:36:44Z")

</div>

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

[Previous page](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184.md?page=1)

[Next page](https://discourse.processing.org/t/permission-issue-in-reading-file-from-external-storage/34184.md?page=3)
