Can't load PImage

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:


And this is the error I get when the sketch loads

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.content.ContextWrapper.getFileStreamPath(
	at processing.core.PSurfaceNone.getFileStreamPath(
	at processing.core.PApplet.sketchPath(
	at processing.core.PApplet.createInputRaw(
	at processing.core.PApplet.createInput(
	at processing.core.PApplet.loadImage(
	at processing.test.notsimplechess.notSimpleChess$ImageDB.<init>(
	at processing.test.notsimplechess.notSimpleChess.setup(
	at processing.core.PApplet.handleDraw(
	at processing.core.PSurfaceNone.callDraw(
	at processing.core.PSurfaceNone$

I’m not sure what I should change
Please help

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

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

I use folders…?

The best way is to save them in a folder just above the absolute path.
See here.

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,


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

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

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

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

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

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

Thank you so much! that worked!

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


I have tried this:

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)