Android Filepath Issue

Hi, I have a Android Processing sketch that used to work a few years ago but I need to update it and can’t get it to run. It seems like there is a problem with having the path in the filename string but this used to work…

for (int i=0; i<numFrames; i++) {
    String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png";
    imageSequence[i] = loadImage(imageName);
    println("Image "+imageName+" was loaded as "+imageSequence[i]);

Any idea how to work around this problem? Ideally I would like to keep my code as is and figure out how to make it run on my device.



   Process: processing.test.pixelpetal_v09, PID: 1579
   java.lang.IllegalArgumentException: File sequences/allseq_pixelData/pixelData00000.png contains a path separator
       at android.content.ContextWrapper.getFileStreamPath(
       at processing.core.PApplet.sketchPath(Unknown Source)
       at processing.core.PApplet.createInputRaw(Unknown Source)
       at processing.core.PApplet.createInput(Unknown Source)
       at processing.core.PApplet.loadImage(Unknown Source)
       at processing.test.pixelpetal_v09.pixelpetal_v09.loadImageSequence(
       at processing.test.pixelpetal_v09.pixelpetal_v09.setup(
       at processing.core.PApplet.handleDraw(Unknown Source)
       at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
       at android.opengl.GLSurfaceView$GLThread.guardedRun(
       at android.opengl.GLSurfaceView$


This is the fileSeparator standard issue (and i have already put answers for it in the “old” forum); till your images are in the data folder at the first level loadImage() works but if you are using subfolders it fires this error ; in order to get rid of it you have to use android AssetManager and list your subfolders (or folders/subfolders…): it will return an array of all the files inside them and so you can get your image using loadImage(myarray[i]). Of course i suppose that your images are not in the external sd card but in your app!

Please cross-link your post:

I suggest you continue any other discussion in this forum.

****EDIT: Additional relevant links parallel in APDE:


@Andres This is a suggestion of how to handle files with dataPath(). @Akenaton has a good point with his approach. I have a suggestion in the above link. I have to think a little bit harder to see how it could be implemented in the source code, to be able to use dataPath the same way as in processing Java.


@kfrajer, thanks so much for your help… this works perfectly…

I’m linking the thread again in case others have the same issue…


@kfrajer I spoke too soon…

While the code works, it is really slow…

I am using the code read an image sequence and the animations that usually run at 24fps are running at half of that.

The images are tiny PNG files (approx 300 bytes each)…

Any idea how I could increase the performance?



You would need to put together an MCVE to be able to reproduce the problem. Maybe check if you are working your images too much. For instance, are you actively resizing your images in draw()? Are you loading files in this function? Very hard to make suggestions without seeing your actual code.


I am scaling them so I can see them for debug purposes…

Let me try without that and see what happens… the images are only 394x7 pixels so they are hard to see…

I’ll report back…



Hi, @kfrajer I tracked down the slowness to Control P5.

I created a new post as this is a different issue.