[英]Permission denied Exception when creating new file
i want to create new file iam using this code 我想使用此代码创建新文件IAM
try {
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "Contacts.vcf");
file.createNewFile();
} catch (IOException ioe)
{ioe.printStackTrace();}
and using this permission 并使用此权限
<permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS" ></permission>
but it keeps givinh me exeption that says Permission denied
但是它让我一直不满,说
Permission denied
您需要在清单文件中使用此权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
当您在External Storage(SD CARD) or Internal Storage
写入任何文件时,必须在清单文件中添加权限...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
将此权限添加到清单文件中
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Give WRITE_EXTERNAL_STORAGE permission to your AndroidManifest file as shown below: 将WRITE_EXTERNAL_STORAGE权限授予您的AndroidManifest文件,如下所示:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
.........
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.