We are about to switch to a new forum software. Until then we have removed the registration on this forum.
im writing a visualiser and need save and load settings here is a quick save file function.
still working on the string save function and open function.
got this from stackoverflow works to save file to Android internal storage SDCARD.
import android.os.Environment; // need this for Environment Android stuff
public void SaveFile() {
try { String filename="visualiser.txt"; String directory = new String(Environment.getExternalStorageDirectory().getAbsolutePath() ); save(directory + "/" + filename); } catch (Exception e) {
} }
just call SaveFile(); or what ever you want to call it... you will need to set sketch permissions to WRITE_EXTERNAL_STORAGE for file io.
anyone know of a simple method to read write load file into a string.
seen a few methods but it seems overly complicated. createbuffer writebuffer etc.
im no expert in android or java so dont ask me how this works. but its sort of easy to follow. ( declare name/find path/savefile/catch error etc).
Answers
added a bit more to save any value using str() to string.
public void SaveFile() {
try { String filename="visualiser.txt";
String words = "Zmod"+str(Zmod)+"Mmod"+str(Mmod)+"Smod"+str(Smod)+"Fmod"+str(Fmod); String[] list = split(words, ' ');
}
this saved the file in internal sdcard with my presets..... I don't know why this wont post code properly on here as usual.
import android.os.Environment;
public void SaveFile() {
try {
String filename="visualiser.txt";
}
public void LoadFile() {
try { String filename="visualiser.txt"; String directory = new String(Environment.getExternalStorageDirectory().getAbsolutePath() );
String[] load = loadStrings(directory+ "/"+ filename); for (LC=0; LC<load.length; LC++) { //for loop load to global array. dataload[LC]=load[LC]; //dataload global string, load local string. }
dataloadlength = load.length; // this is for length number of lines. } catch (Exception e) {} }
and that's it SAVEFILE WRITEFILE LOADFILE Android....took me a day but got it at last.....!!!!
it still wont post code correctly on here don't know why but this works great tested on android 4.1
https://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text
THAT S EVIDENT
Please format your code