I am trying to write a basic "notepad" app for a school project.
I have created the main class with an editText
which I save as String
textOutput.
I have used the following to save the string to a file:
FileOutputStream fos = openFileOutput(textOutput, Context.MODE_PRIVATE);
fos.write(textOutput.getBytes());
fos.close();
However Android Developers reference says in order to read I should use the following steps:
To read a file from internal storage:
- Call
openFileInput()
and pass it the name of the file to read. This returns a FileInputStream
.
- Read bytes from the file with
read()
.
- Then close the stream with
close()
.
What does this mean, and how do I implement it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…