英文:
My Root Folder isn't create in android 10?
问题
我下载音乐并希望在我的回收站中播放,所有安卓设备上都正常,但在安卓10上未能创建根目录。以下是我的代码:
File parent = new File(Environment.getExternalStorageDirectory().toString(), ".RingTones2020");
final String songPath = "/" + arrayListNames[pos] + ".mp3";
final String loc = parent + songPath;
final File checkFile = new File(parent, songPath);
请帮助我...
英文:
I Download music and want to play in my recycler, everything is ok in all android but in android 10 the root isn't created, here is my code :
File parent = new File(Environment.getExternalStorageDirectory().toString(), ".RingTones2020");
final String songPath = "/" + arrayListNames[pos] + ".mp3";
final String loc = parent + songPath;
final File checkFile = new File(parent, songPath);
Please Help me...
答案1
得分: 1
getExternalStorageDirectory
在Android 10中已被弃用,您应该查看访问存储的新限制,称为Scoped Storage。仅适用于Android 10,您可以选择退出并在清单中添加requestLegacyExternalStorage
标志,但Scoped Storage将在Android 11及更高版本中变为强制性。
英文:
getExternalStorageDirectory
is deprecated in Android 10, you should check out new restrictions for accessing storage called Scoped Storage. for just Android 10 you can opt out and add requestLegacyExternalStorage
flag to manifest, but Scoped Storage will be mandatory in Android 11 and above
答案2
得分: 1
在 Api 级别 29 中,此方法已被弃用。
您无法直接访问用户的存储。
如果您想要保存任何文件,有一些基于您的用例的方法。
- 作用域存储(其他应用无法访问)
- 使用 MediaStore(用于媒体文件)
详细信息请参见此处。
英文:
In Api level 29 this method is deprecated..
You can't access the user's storage directly..
If you want to save any files, there will be few ways based on your use cases..
- Scoped storage (not accessible for other apps)
- Using MediaStore (for media files)
See here for more details
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论