public void loadFile(File infile) throws FileNotFoundException {
InputStream inputStream = openFileInput(String.valueOf(infile));
System.out.println("=====READING========");
try {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader sc = new BufferedReader(inputStreamReader);
String temp = "";
while ( (temp = sc.readLine()) != null ) {
System.out.println(sc.readLine());
}
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
This is reader
public void saveGame(File outFile) throws FileNotFoundException {
// Name + UserInfo + CVList+
FileOutputStream os = openFileOutput(String.valueOf(outFile), Context.MODE_PRIVATE);
PrintWriter printWriter = new PrintWriter (os); //set up a writer
String content=userInfo.toString();
content=content+ tempList.toString();//set up the data to be printed
printWriter.println (content);//print it
System.out.println(content);
printWriter.flush();
printWriter.close ();
}
This is writer.
I just got this code from googling whilte finding out ways to r/w .txt files.
The codes are working, but I am wondering since this is android version.
1. Where are the text files stored? I can see InputStreamReader and FileOutputStream is doing something about it, but what is it doing?
2. Do the text files get deleted when app gets updated?