Home > Enterprise >  Android 11 can't load pdf file
Android 11 can't load pdf file

Time:12-20

In my app I can't load pdf file. I can load another files (images) from the same folder, but when I trying load pdf file, I get java.io.FileNotFoundException: /storage/emulated/0/DCIM/1.pdf: open failed: EACCES (Permission denied) but I don't get such esception when I load images. I have all permissions: <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> android:requestLegacyExternalStorage="true"

CodePudding user response:

In Android 11 external storage was restricted. Try this https://developer.android.com/training/data-storage/app-specific

CodePudding user response:

1.Try using file Provider

2.FileProvider is a special subclass of ContentProvider that facilitates secure sharing of files associated with an app by creating a content:// Uri for a file instead of a file:/// Uri.

3 it should work

  • Related