我目前正在嘗試將當前時間粘貼到Android應用程序的文件中。代碼如下所示,但文件未創建。我已經允許我的應用程序通過清單在SD卡上寫入。有任何想法嗎?在Android上寫入文件問題
Time today = new Time(Time.getCurrentTimezone());
today.setToNow();
try {
File myFile = new File("/sdcard/mysdfile.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter =
new OutputStreamWriter(fOut);
SimpleDateFormat dF = new SimpleDateFormat("HHMMSS");
StringBuilder current = new StringBuilder(dF.format(today));
myOutWriter.append(current);
myOutWriter.close();
fOut.close();
}
嘗試'File myFile = new File(「sdcard/mysdfile.txt」);'一次。 – Lucifer 2012-08-07 02:47:22
沒有工作。感謝您的建議。 – GGe 2012-08-07 02:53:02