my app is supposed to store some data in a text file. Every time when the app is started the data is read and every time the app is closed the data is wiped out from the text file and new data about the last session is saved.
Now I don't have problem reading in data:
InputStream is = getResources().openRawResource(R.raw.myFile);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
The trouble is when I write to the file. Obviously it has to be accessed somehow by the resources but R.raw.myFile
results only in InputStream and I have to pass a string to the openFileOutput
. This is the code in question:
FileOutputStream fos = openFileOutput(getResources().openRawResource(R.raw.myFile), MODE_PRIVATE);
So it seems that this won't work. Is there any other way to write to the file in the raw folder?