java.io.filenotfoundexception open failed eacces (permission denied) on device

后端 未结 11 1881
萌比男神i
萌比男神i 2020-12-08 22:03

The following code which consists of downloading a file from a server and save it in the storage works fine when the device has an internal storage.
But when I tried it

相关标签:
11条回答
  • 2020-12-08 22:34

    This attribute is "false" by default on apps targeting Android 10 or higher.

    <application android:requestLegacyExternalStorage="true" ... > ... </application>

    0 讨论(0)
  • 2020-12-08 22:35

    It is possible that the device requires that you manually give the permissions to the cell phone, check your equipment and check that the write permission is activated on your device.

    0 讨论(0)
  • 2020-12-08 22:36

    Try using mkdirs instead of mkdir. If you are creating a directory path and parent doesn't exist then you should use mkdirs.

    0 讨论(0)
  • 2020-12-08 22:46

    I had the same problem, and i solved it by disabling file transfer from device to computer. Because if u enable file transfer, sd card is not accessible to debugging application.

    0 讨论(0)
  • 2020-12-08 22:49

    i have done very silly mistake. I have already put in AndroidManifest.xml

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

    and also add permission in java file,as get permission pragmatically. But there is mistake of Manifest.permission.READ_EXTERNAL_STORAGE. Please use Manifest.permission.WRITE_EXTERNAL_STORAGE.

    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, requestCode);
    
    0 讨论(0)
提交回复
热议问题