I am trying to find a file I have saved in android studio. I have tried everything: putting the full directory, putting the the file in a new folder in that directory, using file.getAbsolutePath()
, declaring a file before or putting the file directly into the reader(BufferedReader r = new BufferedReader(new FileReader("history.txt"));
Here is the code:
File file = new File("Extra Files/history.txt");
BufferedReader r = new BufferedReader(new FileReader(file.getAbsolutePath()));
String scores = r.readLine();
r.close();
No matter what I try it does not seem to work any other ideas, can you not use text files like this in android studio or ???
public void write_score(int ns) throws IOException {
File file = new File(context.getFilesDir(), "history.txt");
BufferedWriter w = new BufferedWriter(new FileWriter(file));
w.append(String.valueOf(ns)).append(",");
w.close();
}