I am trying to write a file to internal memory in my android application, however, although this code is called, later when I try to read the file the app crashes with the fileNotFound exception. I am attempting to write an array, with each reference on a new line.
try{
File myOutputFile = new File ("data/data/com.example.referencetool/files", filename );
FileWriter fw = new FileWriter(myOutputFile, true);
BufferedWriter bw = new BufferedWriter(fw);
if(isFirstTime){
myOutputFile.createNewFile();
}
int i = 0;
while(i<=toSave.length){
if(toSave[i].equals(null)){
bw.write("null");
}
else{
bw.write(toSave[i]);
}
bw.newLine();
i++;
}
bw.flush();
bw.close();
}
catch(Exception e){
e.printStackTrace();
}
Thanks!