# Can't load PImage

**URL:** <https://discourse.processing.org/t/cant-load-pimage/17696>\
**Category:** Processing for Android\
**Created:** [February 10, 2020, 5:47pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696 "2020-02-10T17:47:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DogeMastr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dogemastr/32/689_2.png) [@DogeMastr](https://discourse.processing.org/u/DogeMastr)\
**Post date:** [February 10, 2020, 5:47pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/1 "2020-02-10T17:47:08Z")

</div>

I’m working on a project where I have to load a ton of images into an array list, The code works on Java fine and good but when I switch over to Android and export it to my phone it crashes.

My folder set up is like this:

```auto
/sketch/data/skins/

```

And this is the error I get when the sketch loads

```auto
FATAL EXCEPTION: Animation Thread
Process: processing.test.notsimplechess, PID: 24727
java.lang.IllegalArgumentException: File data/skins/default/00.png contains a path separator
	at android.app.ContextImpl.makeFilename(ContextImpl.java:2540)
	at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:752)
	at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:228)
	at processing.core.PSurfaceNone.getFileStreamPath(PSurfaceNone.java:317)
	at processing.core.PApplet.sketchPath(PApplet.java:5452)
	at processing.core.PApplet.createInputRaw(PApplet.java:4977)
	at processing.core.PApplet.createInput(PApplet.java:4809)
	at processing.core.PApplet.loadImage(PApplet.java:3949)
	at processing.test.notsimplechess.notSimpleChess$ImageDB.<init>(notSimpleChess.java:1001)
	at processing.test.notsimplechess.notSimpleChess.setup(notSimpleChess.java:84)
	at processing.core.PApplet.handleDraw(PApplet.java:1835)
	at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:476)
	at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:516)

```

I’m not sure what I should change  
Please help  
Thanks

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [February 10, 2020, 6:48pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/2 "2020-02-10T18:48:50Z")

</div>

> [@DogeMastr](#):
>
> File data/skins/default/00.png contains a path separator

Do you really use a ‘/’ character in your file name?

---

<div class="post-metadata">

**Author:** ![DogeMastr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dogemastr/32/689_2.png) [@DogeMastr](https://discourse.processing.org/u/DogeMastr)\
**Post date:** [February 10, 2020, 7:03pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/3 "2020-02-10T19:03:11Z")

</div>

```auto
      PImage temp = loadImage("data/skins/default/0"+i+".png");

```

I use folders…?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [February 10, 2020, 8:15pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/4 "2020-02-10T20:15:18Z")

</div>

The best way is to save them in a folder just above the absolute path.  
See [here](https://discourse.processing.org/t/android-cannot-get-access-to-data-folder/14636/2).

---

<div class="post-metadata">

**Author:** ![DogeMastr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dogemastr/32/689_2.png) [@DogeMastr](https://discourse.processing.org/u/DogeMastr)\
**Post date:** [February 10, 2020, 9:03pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/5 "2020-02-10T21:03:51Z")

</div>

I looked at the other page and put in the permissions (read & write external storage) and that didn’t work same error, I’m not saving the files I’m loading them.

My file system is like this,

```auto
/SketchName
   SketchName.pde
   /data
      /skins
         /default
            00.png

```

This is the array loading loop (that works on java)

```auto
for (int i = 0; i < 6; i++) {
      temp = loadImage("data/skins/default/0"+i+".png");
      temp.resize((int)spacing, (int)spacing);
      lightDefault.add(temp);
      temp = loadImage("data/skins/default/1"+i+".png");
      temp.resize((int)spacing, (int)spacing);
      darkDefault.add(temp);
}

```

I don’t see what the difference would be by putting everything down a subfolder

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [February 10, 2020, 11:00pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/6 "2020-02-10T23:00:06Z")

</div>

I see.  
If it is only for loading I guess you need to let out the data folder, because it starts searching from there.  
Like:

```auto
temp = loadImage("skins/default/1"+i+".png");

```

Edit: I mean let out the string “data” from the function. Not the folder itself.

---

<div class="post-metadata">

**Author:** ![DogeMastr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dogemastr/32/689_2.png) [@DogeMastr](https://discourse.processing.org/u/DogeMastr)\
**Post date:** [February 11, 2020, 4:57pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/7 "2020-02-11T16:57:54Z")

</div>

Thank you so much! that worked!

---

<div class="post-metadata">

**Author:** ![Kvi](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kvi](https://discourse.processing.org/u/Kvi)\
**Post date:** [January 25, 2021, 1:42pm UTC](https://discourse.processing.org/t/cant-load-pimage/17696/8 "2021-01-25T13:42:17Z")

</div>

I’m sorry for upping this old theme,but i have same problem on APDE.  
I can’t read the file from subfolder.

```auto
|-data
  |-assets
    |-some.jpg

```

I have tried this:

```auto
PImage img=loadImage(sketchPath("assets")+"/some.jpg"); //this one works,but only in Preview mode
//And this
PImage img=loadImage("data/assets/some.jpg");
// And this
PImage img=loadImage("assets/some.jpg");

```

After making .apk no one works(i tried other devices too)

P.S. my device is Xiaomi Redmi Note 5(android verion 8)
