Android 4.4系统 - 二次SD卡上创建应用程序目录应用程序、卡上、目录、系统

2023-09-07 01:15:37 作者:此男子高姿态.你高攀不起

我知道即将SD卡由谷歌的Andr​​oid 4.4引入访问的变化。然而,在我的应用程序需要能够将数据存储到一些移动/次要SD卡上。

当我创建的二次使用默认的文件管理器应用程序文件夹(app.xyz.com),那么我能够创建内部迪尔斯和文件。但默认情况下这样的目录这么想的二次SD卡上。

所以,我想以编程方式创建我的应用程序中的应用程序特定的目录...

你有什么想法如何做到这一点?简单file.mkdirs(),即使有正确的应用程序相关的路径,不能正常工作。权限错误...

我有花已经是两个天尝试找到一种方法,没有任何成功

感谢您的帮助!

解决方案   

你有任何想法如何做到这一点?

使用 getExternalFilesDirs()(注意是复数)。如果该返回多个条目,第二个和后续的是在可移动介质。这些目录可以读取和写入没有任何权限的Andr​​oid 4.4。

Android移动开发基础案例教程 第2章 Android UI开发

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!!!

解决方案

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.

 
精彩推荐
图片推荐