-1
嗨我是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();
}
哪裏是你的textBox.getText()。的toString() ?你的按鈕的onClick()方法?什麼問題? –
http://www.mail-archive.com/[email protected]/msg20408.html查看鏈接它會幫助你。 –