[英]Android | Creating Folder in External Storage Root Directory on Android 11+
As is well known, Google turned the authorization concept upside down from Android 11 and completely changed it.众所周知,Google 将授权概念从 Android 11 颠倒过来,彻底改变了它。
I looked in the Android documentation jungle, but didn't find an answer to the question of whether it's still possible to create a folder in the root directory of External Storage (named /storage/emulated/0/).我查看了 Android 文档丛林,但没有找到关于是否仍然可以在外部存储的根目录(名为 /storage/emulated/0/)中创建文件夹的问题的答案。 If yes, how?
如果是,如何?
My app writes at android <= 10 in root.我的应用程序在根目录中写入 android <= 10。
interim solution could be like this:临时解决方案可能是这样的:
public static String getStorageDir(){
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + "/myNewFolder";
....
} else {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myNewFolder";
...
}
But that is suboptimal.但这是次优的。 If a user switches from Android 10 to Android 11+, then there is a big problem.
如果用户从 Android 10 切换到 Android 11+,那么问题就大了。 What additional code do I need to allow creating a folder in ROOT on Android 11+?
我需要哪些额外的代码才能在 Android 11+ 上的 ROOT 中创建文件夹?
It is claimed that Google Play denies "MANAGE_ALL_FILES" permission directly.据称,Google Play 直接拒绝“MANAGE_ALL_FILES”权限。 Is that true and is it still the case?
这是真的吗?现在仍然如此吗? Does anyone have experience with this?
这个事情谁有经验?
Use ACTION_OPEN_DOCUMENT_TREE to let the user create the wanted directory.使用 ACTION_OPEN_DOCUMENT_TREE 让用户创建想要的目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.