我目前正在尝试将当前时间粘贴到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