我找到了一個代碼並根據我的應用程序編輯了一下。它是以字節爲單位向Android上的txt寫文本。我得到這個錯誤,Exception 'open failed: EACCES (Permission denied)' on Android開放失敗:Android中的EACCES(權限被拒絕)
正如上面的鏈接所述,我改變了它的地方,其中與write_external_storage相關的用戶權限位於我的Android Manifest文件中。但是,在該文件中,我收到「標籤出現在標籤後面」警告,導致我再次得到相同的錯誤。
預先感謝您
if (response.equals("tag OK " + param[2]
+ " authenticated (Success)")) {
mySuccessfulLogin = param[0] + "\n"
+ param[1] + "\n" + param[2]
+ "\n" + newpassword;
myDirectory = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+"Users/macbookpro/Documents/CS328/Android_IMAP";
File custdir = new File(myDirectory);
if(!custdir.exists())
{
custdir.mkdirs();
}
File savedir=new File(custdir.getAbsolutePath());
File file = new File(savedir, "LastLogin");
if(file.exists())
{
file.delete();
}
FileOutputStream fos;
byte[] data = mySuccessfulLogin.getBytes();
try {
fos = new FileOutputStream(file);
fos.write(data);
fos.flush();
fos.close();
// Toast.makeText(, "File Saved", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
//Toast.makeText(getBaseContext(), "Error File Not Found", Toast.LENGTH_LONG).show();
Log.e("fnf", ""+e.getMessage());
// handle exception
} catch (IOException e) {
// handle exception
// Toast.makeText(getBaseContext(), "Error IO Exception", Toast.LENGTH_LONG).show();
}
}
請發佈您的日誌請 – Lukos 2014-11-14 16:21:44