【发布时间】:2015-01-12 00:55:26
【问题描述】:
我找到了一个代码并根据我的应用程序进行了一些编辑。它是关于在 Android 上以字节为单位将文本写入 txt。我收到了这个错误,Exception 'open failed: EACCES (Permission denied)' on Android
如上面的链接所述,我更改了与 write_external_storage 相关的用户权限在我的 Android 清单文件中的位置。但是,在该文件中,我收到“标签出现在标签之后”警告导致我再次遇到相同的错误。
提前谢谢你
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();
}
}
【问题讨论】:
-
请发布您的日志
标签: android permission-denied read-write