Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Can't get tables demo to run in Processing 3.0 using example from reference

$
0
0

https://processing.org/reference/Table.html

...provides an example of how to create a table in Processing. In Processing 2.0, I was able to successfully have data persist in an android application area, not requiring external storage permission, within the Data folder. However, with Processing 3.0, I cannot get anything to save and reload and cannot test my old code against android 2.x because the current version of 2.x available for download (2.2.1 I believe) has android mode disabled.

Here is an example. I took the example code from the reference, and reduced it further in an attempt to figure out what is going in in 3.0. No Joy despite over a week of futzing with this and loadStrings, saveStrings, loadTable, saveTable, and a seemingly infinite number of possible locations for data files.

I have come to conclude that load and save of strings and tables needs updated documentation, or there is a bug.

Common themes of the errors I have encountered: if saveTable

1) example documentation that includes file names with prefix of "data/" but error message that says "invalid; path separator cannot be used".

2) crash in animation string.

Here is an example: If saveTable is not commented out, the stacktrace at the bottom is generated.

****Can anyone provide a working example of loadString / saveString, or loadTable / saveTable, along with associated directory structure and example file?****

Thank you Joe Miller Tucson

Table table; int xint=0; String xstring;

void setup() {

table = new Table(); xstring = "0"; xint = int(xstring);

table.addColumn("id"); table.addColumn("x");

TableRow newRow = table.addRow(); newRow.setInt("id", table.lastRowIndex()); newRow.setString("x", xstring);

saveTable(table, "data/tabledemo.csv"); }

void draw() { println(xint); xint=xint+1; }

/* FATAL EXCEPTION: Animation Thread Process: processing.test.tabledemo, PID: 4624 java.lang.IllegalArgumentException: File data/tabledemo.csv contains a path separator at android.app.ContextImpl.makeFilename(ContextImpl.java:2288) at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:1079) at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:195) at processing.core.PApplet.sketchPath(Unknown Source) at processing.core.PApplet.savePath(Unknown Source) at processing.core.PApplet.saveFile(Unknown Source) at processing.core.PApplet.saveTable(Unknown Source) at processing.core.PApplet.saveTable(Unknown Source) at processing.test.tabledemo.tabledemo.setup(tabledemo.java:36) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:841) */


Viewing all articles
Browse latest Browse all 941

Trending Articles