Android IOException: открыть не удалось: EACCES (разрешение отказано)
У меня есть код, который обновляет теги song ID3, он отлично работает для файлов внутри хранилища устройства, но выдает ошибку "java.io.IOException: open failed: EACCES (Permission denied)" для файлов во внешнем хранилище. Я также установил разрешение WRITE_EXTERNAL_STORAGE в манифесте, но без помощи. предоставив мой код ниже, любая помощь будет оценена.
protected void EditTags(final Song song,String tite, String album, String artist){
File src = new File(song.getPath());
MusicMetadataSet src_set = null;
try {
src_set = new MyID3().read(src);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // read metadata
if (src_set == null) // perhaps no metadata
{
Log.i("NULL", "NULL");
}
else
{
try{
IMusicMetadata metadata = src_set.getSimplified();
String artist1 = metadata.getArtist();
String album1 = metadata.getAlbum();
String song_title = metadata.getSongTitle();
Number track_number = metadata.getTrackNumber();
Log.i("artist", artist1);
Log.i("album", album1);
}catch (Exception e) {
e.printStackTrace();
}
MusicMetadata meta = new MusicMetadata("name");
meta.setAlbum(tite);
meta.setArtist(artist);
meta.setAlbum(album);
try {
new MyID3().update(src, src_set, meta);
Toast.makeText(context, "Tags Updated", Toast.LENGTH_SHORT).show();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ID3WriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // write updated metadata
}
scanner=new MediaScannerConnection(context,
new MediaScannerConnection.MediaScannerConnectionClient() {
public void onScanCompleted(String path, Uri uri) {
scanner.disconnect();
}
public void onMediaScannerConnected() {
scanner.scanFile(song.getPath(), "audio/*");
}
});
scanner.connect();
}
Мой Андроидманифест.xml: -
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.musicplayer" >
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
.
.
</application>
</manifest>
Мой Журнал: -
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ java.io.IOException: open failed: EACCES (Permission denied)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at java.io.File.createNewFile(File.java:941)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at java.io.File.createTempFile(File.java:1006)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at org.cmc.music.myid3.MyID3.update(MyID3.java:60)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at com.musicplayer.AlbumSongAdapter.EditTags(AlbumSongAdapter.java:280)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at com.musicplayer.AlbumSongAdapter$3.onClick(AlbumSongAdapter.java:240)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:160)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at android.os.Looper.loop(Looper.java:135)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5254)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:372)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
08-01 12:02:55.388 8085-8085/com.musicplayer W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
08-01 12:02:55.389 8085-8085/com.musicplayer W/System.err﹕ Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
08-01 12:02:55.389 8085-8085/com.musicplayer W/System.err﹕ at libcore.io.Posix.open(Native Method)
08-01 12:02:55.389 8085-8085/com.musicplayer W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
08-01 12:02:55.389 8085-8085/com.musicplayer W/System.err﹕ at java.io.File.createNewFile(File.java:934)
08-01 12:02:55.389 8085-8085/com.musicplayer W/System.err﹕ ... 12 more