Path Separator error [Android mode]


#1

I’ve got some troubles with path in Android mode. In Java mode, I use:

Table t = loadTable("data/Snake" + snakeNo + ".csv");

It works well. In Android mode, I add the following code:

String path = dataPath("Snake" + snakeNo + ".csv");
Table t = loadTable(path);

I want to get access to files Snakei.csv but failed in Android mode
I think it will work, but got this exeption

FATAL EXCEPTION: Animation Thread
java.lang.IllegalArgumentException: File /data/data/processing.test.smartsnakescombine/files/Snake1.csv contains a path separator
at android.app.ContextImpl.makeFilename(ContextImpl.java:1974)
at android.app.ContextImpl.openFileInput(ContextImpl.java:700)
at android.content.ContextWrapper.openFileInput(ContextWrapper.java:167)
at processing.core.PSurfaceNone.openFileInput(PSurfaceNone.java:331)
at processing.core.PApplet.createInputRaw(PApplet.java:5123)
at processing.core.PApplet.createInput(PApplet.java:4931)
at processing.core.PApplet.loadTable(PApplet.java:4393)
at processing.core.PApplet.loadTable(PApplet.java:4377)
at processing.test.smartsnakescombine.SmartSnakesCombine$Snake.loadSnake(SmartSnakesCombine.java:1149)
at processing.test.smartsnakescombine.SmartSnakesCombine$World.loadBestSnakes(SmartSnakesCombine.java:2076)
at processing.test.smartsnakescombine.SmartSnakesCombine$World.snakeFusion(SmartSnakesCombine.java:2083)
at processing.test.smartsnakescombine.SmartSnakesCombine.keyPressed(SmartSnakesCombine.java:111)
at processing.core.PApplet.keyPressed(PApplet.java:2608)
at processing.core.PApplet.handleKeyEvent(PApplet.java:2542)
at processing.core.PApplet.dequeueEvents(PApplet.java:2062)
at processing.core.PApplet.handleDraw(PApplet.java:1873)
at processing.core.PSurfaceNone.callDraw(PSurfaceNone.java:476)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:516)

Could you tell me how to solve it :grinning::yum:(Thanks in advanced!)


#2

I use that path syntax who run under Android or Windows :slight_smile:
JSONArray values = loadJSONArray(“Data\\Index.json”);

Using two \