# Android Filepath Issue

**URL:** https://discourse.processing.org/t/android-filepath-issue/2118
**Category:** Processing for Android
**Created:** [July 27, 2018, 3:50am UTC](https://discourse.processing.org/t/android-filepath-issue/2118 "2018-07-27T03:50:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)
#### Post date: [July 27, 2018, 3:50am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/1 "2018-07-27T03:50:53Z")

</div>

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…

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

Thanks

Phil

```auto
FATAL EXCEPTION: GLThread 787
   Process: processing.test.pixelpetal_v09, PID: 1579
   java.lang.IllegalArgumentException: File sequences/allseq_pixelData/pixelData00000.png contains a path separator
       at android.app.ContextImpl.makeFilename(ContextImpl.java:2366)
       at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:1120)
       at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:191)
       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(pixelpetal_v09.java:96)
       at processing.test.pixelpetal_v09.pixelpetal_v09.setup(pixelpetal_v09.java:116)
       at processing.core.PApplet.handleDraw(Unknown Source)
       at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

```

---

<div class="post-metadata">

### Author: ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)
#### Post date: [July 27, 2018, 8:54am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/2 "2018-07-27T08:54:49Z")

</div>

@philspitler===

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!

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 27, 2018, 6:09pm UTC](https://discourse.processing.org/t/android-filepath-issue/2118/3 "2018-07-27T18:09:42Z")

</div>

Please cross-link your post: [https://forum.processing.org/two/discussion/28082/filepath-issue#latest](https://forum.processing.org/two/discussion/28082/filepath-issue#latest)

I suggest you continue any other discussion in this forum.

\*\*\*\*EDIT: Additional relevant links parallel in APDE: [https://github.com/Calsign/APDE/issues/54#issuecomment-413367412](https://github.com/Calsign/APDE/issues/54#issuecomment-413367412)

Kf

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 27, 2018, 6:20pm UTC](https://discourse.processing.org/t/android-filepath-issue/2118/4 "2018-07-27T18:20:01Z")

</div>

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

Kf

---

<div class="post-metadata">

### Author: ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)
#### Post date: [July 31, 2018, 12:24am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/5 "2018-07-31T00:24:19Z")

</div>

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

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/comment/124659#Comment_124659)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

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

Phil

---

<div class="post-metadata">

### Author: ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)
#### Post date: [July 31, 2018, 1:12am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/6 "2018-07-31T01:12:10Z")

</div>

@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?

Cheers.

Phil

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [July 31, 2018, 1:20am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/7 "2018-07-31T01:20:58Z")

</div>

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.

Kf

---

<div class="post-metadata">

### Author: ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)
#### Post date: [July 31, 2018, 1:23am UTC](https://discourse.processing.org/t/android-filepath-issue/2118/8 "2018-07-31T01:23:51Z")

</div>

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…

Thanks

Phil

---

<div class="post-metadata">

### Author: ![philspitler](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@philspitler](https://discourse.processing.org/u/philspitler)
#### Post date: [July 31, 2018, 10:47pm UTC](https://discourse.processing.org/t/android-filepath-issue/2118/9 "2018-07-31T22:47:48Z")

</div>

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

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

> [@Control P5 slowdown](https://discourse.processing.org/t/control-p5-slowdown/2250):
>
> I have a weird issue where my sketch gets slower and slower the more Control P5 buttons I have. This behavior only shows up in Android mode, it seems fine when running in Java on OSX. If you look at my code you will see I draw a UI with a bunch of buttons… If I comment out that code my sketch returns a value of 10 seconds which is correct for 24fps. If I leave all the buttons in my sketch the time goes up to 22 seconds… If I leave half the buttons in it is somewhere in the middle… I only create…

Thanks,

Phil
