How do I open and write to a file in an Android class outside an activity?
FileWriter
is my external class, initialized from MainActivity
. The following line in FileWriter
:
FileOutputStream fos = openFileOutput("filename", Context.MODE_PRIVATE);
Yields this compilation error:
The method openFileOutput(String, int) is undefined for the type FileWriter
I guess that the class requires some application context - how do I pass it?