Skip to content Skip to sidebar Skip to footer

Create Package Directory In ../android/data Denied On Sd-cards On Android >4.4

I have trouble creating the 'com.foo.Example' folder of my app in '/storage/extSdCard/Android/data' from inside the app. If created manually with a file manager there is no trouble

Solution 1:

I'm assuming you're using getExternalFilesDir(), if not, you'll want to convert to it. getExternalFilesDir(), when passed null, will create a private directory for your application to write to if it doesn't already exist and return the handle for that.

You'll want to check out this guide, which has all the info you need on how to write to external storage.

As for why you're having this issue on KitKat, Google changed the permission model for external storage to prevent apps from writing to arbitrary folders on the SD card, which provides better security, as well as keeping things better organised. However, the cool part is that getExternalFilesDir() doesn't even require a permission to use! It's always available to your application.

Hope that helps!

Post a Comment for "Create Package Directory In ../android/data Denied On Sd-cards On Android >4.4"