[英]“Cannot resolve method 'openFileOutput(Java.lang.String, int)'”
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)'" 但是在openFileOutput上我收到错误“无法解析方法'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: 使用
ctx
访问noraml类中的openFileOutput
方法,该方法不扩展Context
类的任何子类:
fos = ctx.openFileOutput(FILENAME, ctx.MODE_PRIVATE);
Because openFileOutput is define in Context class 因为openFileOutput是在Context类中定义的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.