I have a file that I am trying to read information from and then update the file. I am able to read all the information from the file perfectly but when I go to write to the file, the file is not being written too.
Here is the code I am using to write to the file.
fun saveToFile(context: Context){
try{
Log.d("StatsAdapter", "Finding file.")
val writer = OutputStreamWriter(context.openFileOutput("stats.txt", Context.MODE_PRIVATE))
Log.d("StatsAdapter", "Writing.")
writer.write("Hello")
writer.flush()
writer.close()
} catch (e: IOException) {
Log.d("StatsAdapter", "" + e)
}
}
The file stats.txt is an empty text file in assets on android studio, which gets read fine (I threw some basic information in to check reading). But when I go to write to the file, nothing appears in the file. Any ideas would be greatly appreciated :)