location of directories when using android mode

edited May 2014 in Android Mode

Hi, I have a project that uploads a file to an FTP server, when i run it in JAVA mode it works fine. When i run it in Android mode it connects to the server and begins to upload the test file then throws the error:

java.io.FileNotFoundException: /18-4-2014.txt (No such file or directory) at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)

So it obviously cant find the required file; There are two directories in the sketch folder 1) the "code" folder that holds the FTP library jar file and 2) the "data" folder which holds the text file that i wish to send.

I assumed that the data directory was the first place that the sketch looks for when looking for a particular file (if the path isn't explicitly set) - it seems to find the code directory OK. I have just discovered that in fact it was only working in JAVA mode because there was a copy of the file in the main processing directory (/home/richard/processing).

How do i get it to look in the data directory for required files.

Any help is much appreciated.

Cheers.

Answers

  • Anybody??

  • I at least moved the topic to the Android category, it might find a better audience...

  • How do you open the file? Some functions don't search the data folder, so you must specify the absolute path to the data folder like so: dataPath("myFile.txt") (replacing myFile.txt, depending on your implementation...). dataPath() returns the specified file appended to the path to the data folder.

  • Hi calsign and thanks for the reply - the use of the dataPath() method did the trick in java mode but didn't work in Android mode (threw a file not found exception) which puzzles me a bit cos the call to

    text(dataPath(""),5,40);

    reported the same path to internal storage as the java method

    text(getFilesDir(),5,60);

    So i assume that its working correctly but the call to

    File firstLocalFile = new File(dataPath("15-4-2014.txt"));

    did not work whereas it did in java mode. Could the problem be permissions although i thought internal storage for the app could be freely written to and read from.

    Any Ideas?

    Any help is much appreciated.

    Cheers.

    sketch permissions issue?

Sign In or Register to comment.