Android 4.4 - create application dir on secondary sd card

雨燕双飞 提交于 2019-12-23 04:01:43

问题


I am aware about changes in Access to SD card introduced by Google with Android 4.4. However in my application I need to be able to store data on some removable /secondary sd card.

When I create the application folder (app.xyz.com) on the secondary using default file manager then I am able to create dirs and files inside. But by default such dir dosen't exist on secondary sd card.

So, I would like to create the application specific dir programmatically inside my application…

Do you have any idea how to do this??? Simple file.mkdirs(), even with the correct application related path, doesn’t work. Permission error…

I have spend already two days trying to find a way, without any success

THANKS FOR YOUR HELP!!!


回答1:


Do you have any idea how to do this?

Use getExternalFilesDirs() (note the plural). If that returns more than one entry, the second and subsequent ones are on removable media. Those directories you can read and write to without any permissions on Android 4.4.



来源:https://stackoverflow.com/questions/26006040/android-4-4-create-application-dir-on-secondary-sd-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!