I am having trouble understanding what is going on, because I believed that with Android I must use a path to files, either dataPath or sketchPath. I have used file saving and reading using both and neither, without noticing any difference. These tests were done to try and reach the truth, but I still do not know why these results work, nor why the two mentioned File functions do not.
As can be seen, the reverse seems to be true (!).
Can somebody please tell me what is correct, especially as ‘/’ cannot be used.
I have pressed the formatting button.
//====================================
//These tests done with Apple M2 Mini; Processing 4.3 using the inbuilt IDE
//Android Mode for Processing 4. Samsung S11 Tablet with Android 16.
//dataPath and sketchPath seem not to be required, but do work.
//To complete the tests with & without functions, the appropriate ‘//’ should in turn be removed.
//THE MAIN REQUIREMENTS ARE, 1. how to delete a file. 2.How to test the file exists
//====================================
import java.io.File;
import android.os.Environment;
String savedGames = new String[0];
int sizeW=200, sizeH=200;
void settings(){
size(sizeW,sizeH);
}
void setup(){
//Test with text file.
savedGames = append(savedGames,“abcd”);
File f = new File(“savedGames.txt”);
if(!f.exists()){
saveStrings(“savedGames.txt”,savedGames);
}
savedGames[0] = “efgh”;
f.delete();
savedGames = loadStrings(“savedGames.txt”);
//The results show that the exist() and delete() do nothing, (note !).
//Also, that the file is saved and read.
//====================================
//Test with byte data
// Run once under debug, stop at if() and monitor stepping, for b in debug window.
//In turn change L10 to L11 and L11 to L12. It proves that the new files are saved and read.
//====================================
byte b = new byte[0];
/* b = loadBytes(“mjk-L10.dat”); //Should read 5
b[0] = 11; //Change to 11 & save
saveBytes(“mjk-L11.dat”, b);
b[0] = 9; //Change to 9
b = loadBytes(“mjk-L11.dat”); //Should read 11
*/
//====================================
File s = new File(“mjk-L10.dat”);
// if(s.exists()){
b = loadBytes(“mjk-L10.dat”);
// }
File t = new File(“mjk-L11.dat”);
b[0] = 11;
saveBytes(“mjk-L11.dat”,b);
// if(t.exists()){
b[0] = 9;
b = loadBytes(“mjk-L11.dat”);
// }
}//setup