Home >Java >javaTutorial >Why Does Creating Directories Fail in Android 10 and How Can I Fix It?
Unable to Create Directory in Android 10
Problem:
Creating directories in Android 10 using either File.mkdir() or Files.createDirectory() fails, resulting in false success status and an AccessDeniedException.
Error:
java.nio.file.AccessDeniedException: /storage/emulated/0/Pastebin
Cause:
Android 10 restricts access to external storage locations by default.
Solution:
Use Legacy Storage Access (Android 10 and 11 Only)
Add the following to the
android:requestLegacyExternalStorage="true"
This reverts to the legacy storage model, allowing existing external storage code to function.
Alternative Options
The above is the detailed content of Why Does Creating Directories Fail in Android 10 and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!