Writing files on Android!
in
Android Processing
•
6 months ago
Well, just as I was about to ask a question, in total despair, as to how to save files on Android, I figured it out!
This is what I did and it works on my Nexus 4 (Jelly bean 4.2.2 not rooted):
This is what I did and it works on my Nexus 4 (Jelly bean 4.2.2 not rooted):
- skectch permission: WRITE_EXTERNAL_STORAGE
- on the device, with a terminal app:
- $ mkdir /sdcard/MyStuff
- then, to write a file, it must look "external", think network address...
saveTable(tsv,"//sdcard/MyStuff/data.tsv");
- note the use of leading double slash before the root of the path. For some incredible reason, this convinces Android OS that the path is external. If you don't put that extra slash, you get an error saying it is evil to put path separators in the file-path-name! If you just give a simple filename, then saveTable just fails silently, with no exception ...
This was so hard to figure out!
1