1

When I update from Android 10 to 11, I get "open failed: EACCES (Permission denied)". The procedure is as follows

1.Save files from targetSDK28 app to internal storage(This is a proprietary file.)

/storage/emulated/0/MyAppName/202109259092928414.hoge

2.Update your device from Android 10 to 11

3.Load the file created in step 1 from the app that has been updated to targetSDK30.

FileInputStream in = new FileInputStream(new File("/storage/emulated/0/MyAppName/202109259092928414.hoge"))

file.exists()=true file.canRead()=false

4.An error occurred.

09-16 12:16:40.582 27825 27825 W System.err: java.io.FileNotFoundException: /storage/emulated/0/MyAppName/202109259092928414.hoge: open failed: EACCES (Permission denied) 09-16 12:16:40.583 27825 27825 W System.err: at libcore.io.IoBridge.open(IoBridge.java:492) 09-16 12:16:40.583 27825 27825 W System.err: at java.io.FileInputStream.(FileInputStream.java:160)

I have added and allowed storage permission in Manifest file and also on runtime for reading a file. However there is no Internal Storage Permission request available.

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

and also for Android 10 I was using this attribute also

android:requestLegacyExternalStorage="true"

This does not occur on devices that have not been updated with the OS.

Cocolucoco
  • 11
  • 2
  • android:requestLegacyExternalStorage="true" is deprecated for android 11(targetSDK 30). You need to update code to scope storage to get access to storage for android 11 and above. [link](https://developer.android.com/about/versions/11/privacy/storage) – Nitish Sep 16 '21 at 05:38
  • `However there is no Internal Storage Permission request available.` Your file is on external srorage. – blackapps Sep 16 '21 at 05:49
  • But... What is the question? As what you are reporting does not come as a surprise. Google advised you to move your files before updating. – blackapps Sep 16 '21 at 05:51
  • `android:requestLegacyExternalStorage="true` Your app should keep that in order to run on Android 10 deviced. – blackapps Sep 16 '21 at 05:52
  • If you want access to the file request for MANAGE_EXTERNAL_STORAGE or let user choose file with ACTION_OPEN_DOCUMENT. – blackapps Sep 16 '21 at 05:54
  • `When I update from Android 10 to 11, ` I read it that you are updating your app. – blackapps Sep 16 '21 at 06:10
  • What I want to do is to move the files created by the targetSDK28 app to the in-app area after updating to the targetSDK30 app. – Cocolucoco Sep 16 '21 at 07:11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 22 '21 at 16:26

0 Answers0