I just want to write and read some data but my app doesn´t know the context. Do I have to define the context before I use it?
I´ve got this code from an answer on: How To Read/Write String From A File In Android
private void writeToFile(String data) {
try {
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(context.openFileOutput("config.txt", Context.MODE_PRIVATE));
outputStreamWriter.write(data);
outputStreamWriter.close();
}
catch (IOException e) {
Log.e("Exception", "File write failed: " + e.toString());
}
}
Here is how it looks like in Android Studio: