我找到了一个代码并根据我的应用程序编辑了一下。它是以字节为单位向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