I'm creating a class with some Read/Write from file functions.
String FILENAME = "my_file";
FileOutputStream fos;
public void write(String text, Context ctx)
{
fos = openFileOutput(FILENAME, ctx.MODE_PRIVATE);
try {
fos.write(text.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
But on openFileOutput I get the error "Cannot resolve method 'openFileOutput(Java.lang.String, int)'"
How can I fix it?
Use ctx to access openFileOutput method in noraml class which is not extending any subclass of Context class:
fos = ctx.openFileOutput(FILENAME, ctx.MODE_PRIVATE);
Because openFileOutput is define in Context class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With