SD卡写入是否被阻止? [英] Has SD card writing been blocked?

查看:84
本文介绍了SD卡写入是否被阻止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的应用程序中提供一项功能,以便用户可以将应用程序中使用的媒体或存储文件移至SD卡.

I am trying to provide a functionality in my app that the media or storage files used in my application can be moved to SD card by the user.

我正在尝试使用以下链接中所述的代码

I am trying to use the code as described in below link

http://www.java-samples.com/showtutorial.php ?tutorialid = 1523

但是我得到一个权限异常.当我搜索该权限时,我看到我必须对设备进行root操作.我不想植根我的设备,因为它是非法的,不是吗?是否有任何Android设备模型是从制造商一开始就扎根的?

But I get a permission exception. When I searched for getting that permission, I see that I have to root the device. I don't want to root my device, as it is illegal, no? Is there any android device model that comes rooted from the beginning itself from the manufacturer?

我以前也曾在应用程序设置中看到移至SD卡"选项,但我再也看不到该选项.我还看到设备上安装的大多数文件浏览器应用程序都无法在SD卡上创建文件夹,

Earlier also I used to see a "Move To SD Card" option in the app settings, but I don't see that option any more. I also saw that most of the file browser applications installed in my device are unable to create a folder on the SD card,

请分享一些有关实现此功能的最佳建议方法.我们支持android 4.4至8.0

Please share some light on what's the best recommended way to implement this feature. We are supporting android 4.4 to 8.0

推荐答案

是的,在现代Android版本中,禁止写入sd卡.

Yes writing to the sd card is blocked in modern Android versions.

大多数情况下,您已经读取了整个SD卡的访问权限.

Mostly you have read acces to the whole sd card.

仅写一个应用程序特定的目录,如果您很幸运,该目录在getExternalFilesDirs()返回的第二个项目中可用.

Writing only to one app specific directory which if you are lucky is available in the second item returned by getExternalFilesDirs().

如果要写入整个sd卡,请使用Storage Access Framework.

If you want to write to the whole sd card then use the Storage Access Framework.

例如Intent.ACTION_OPEN_DOCUMENT_TREE.

For instance Intent.ACTION_OPEN_DOCUMENT_TREE.

这篇关于SD卡写入是否被阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆