朋友们,我使用此代码将我的资产文件夹复制到SD卡中,但它显示权限被拒绝但我已获得外部存储权限
复制资产
private void CopyAssets() {
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", e.getMessage());
}
for(String filename : files) {
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open(filename);
out = new FileOutputStream("/sdcard/" +"Good");
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(Exception e) {
Log.e("tag", e.getMessage());
}
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
Logcat显示权限被拒绝
02-16 21:25:14.227: E/tag(405): /sdcard/Good (Permission denied)
02-16 21:25:14.236: E/tag(405): images
02-16 21:25:14.236: E/tag(405): sounds
02-16 21:25:14.236: E/tag(405): webkit
这是我的清单文件权限标记
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />