In what folder shall I store my saved files?

edited April 2014 in Android Mode

Hi all be ye novice or guru! I have written an Android app and it saves a data file in ASCII .stl format (3d object file). I have been saving it to a specific folder on my Samsung Galaxy III phone with no issues, then when my buddy tries the app on his Android tablet there is unexpected behavior. On the tablet the app crashes but upon running it again the load feature works, indicating that the save did occur properly. Here is the code:

  saveStrings(dataPath(path + filename), stlContents);

where previously I have defined the following:

String path = "/storage/emulated/0/Documents/";
String filename = "clayCAD.stl";

and stlContents is a string array holding the entire file. Works great, but why the crash and how to fix it? Do i need to use try(){}catch(Event e){}?

Les

Answers

  • Answer ✓

    I'm not sure why the sketch is crashing... but one thing strikes me as odd: it appears that you pass an absolute path to the dataPath() function (path + filename, which should be /storage/emulated/0/Documents/clayCAD.stl). dataPath() will try to find this file within your sketch's data folder (somewhere in the app's installation directory). This probably isn't what you want.

    Instead, either specify the absolute path only (no dataPath()) or pass a relative path to dataPath() (just filename, but not path).

Sign In or Register to comment.