嗨,我是 Android 开发新手,我正在尝试这个简单的应用程序,我的问题是我试图通过单击按钮将编辑文本中的数据块保存到文件中,但我无法这样做!我的代码块是
saveBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String str = textBox.getText().toString();
try
{
FileOutputStream fOut =
openFileOutput("textfile.txt", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write();
osw.flush();
osw.close();
Toast.makeText(getBaseContext(), "File saved successfully!", Toast.LENGTH_SHORT).show();
Toast.makeText(getBaseContext(), "file path" + getFileStreamPath ("textfile.txt"), Toast.LENGTH_LONG).show();
textBox.setText("");
}
catch (IOException ioe)
{
ioe.printStackTrace();
}