Java openFileOutput()的用途是什么?
我有这段代码。 是否有人可以帮助您了解openFileOutput中的“0”属性在以下代码中代表什么Java openFileOutput()的用途是什么?,java,android,android-context,Java,Android,Android Context,我有这段代码。 是否有人可以帮助您了解openFileOutput中的“0”属性在以下代码中代表什么 public void Save(String fileName) { try { OutputStreamWriter out = new OutputStreamWriter(openFileOutput(fileName, 0)); out.write(EditText1.); out.close();
public void Save(String fileName) {
try {
OutputStreamWriter out =
new OutputStreamWriter(openFileOutput(fileName, 0));
out.write(EditText1.);
out.close();
Toast.makeText(this, "Note Saved!", Toast.LENGTH_SHORT).show();
} catch (Throwable t) {
Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show();
}
}
int:操作模式。
值为0或模式\私有、模式\世界\可读、模式\世界\可写或模式\附加的组合
建议使用常量,但0是上下文。MODE_PRIVATE从的文档中,0表示打开文件的模式。在本例中,0是以下内容的同义词: 文件创建模式:默认模式,其中创建的文件只能由调用应用程序或共享相同用户ID的所有应用程序访问
因此,只有创建该文件的应用程序以后才能访问它。另一个选项是在当前端点打开文件并向其添加额外数据。对于Context.MODE\u private请注意,从API 17开始,不推荐使用MODE\u WORLD\u READABLE和MODE\u WORLD\u WRITEABLE。