Android 13 Tiramisu - Access files in Download Folder - EACCES (Permission denied)

688 views Asked by At

I have an app that downloads some mp3 files into some folder such as /storage/emulated/0/myFolder1/myFolder2/file.mp3

I have added

<uses-permission android:name="android.permission.READ_MEDIA_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />

Before Android 13, after requesting permission it works, but on Android 13, even permission dialog does not show up and I couldn't download the file.

To make Android 13 compatible with minimum effort, I moved the path into Download folder, such as /storage/emulated/0/Download/myFolder2/file.mp3

That way I was able to download the file, but when I try to read it using

FileInputStream fis = new FileInputStream(FullAddress); 
// full address is /storage/emulated/0/Download/myFolder2/file.mp3

That code throws java.io.FileNotFoundException: /storage/emulated/0/Download/myFolder2/file.mp3: open failed: EACCES (Permission denied)

How can I properly read the file that I downloaded on Android 13?

I don't want to use internal app storage, because those files can be replaced from PC or any other way, they must be accessible.

0

There are 0 answers