我的根文件夹不是在 android 10 中创建的?
My Root Folder isn't create in android 10?
我下载音乐并想在我的回收站中播放,一切正常 android 但在 android 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);
请帮帮我...
getExternalStorageDirectory
是 deprecated in Android 10, you should check out new restrictions for accessing storage called Scoped Storage。对于 Android 10,您可以选择退出并添加 requestLegacyExternalStorage
标志以显示,但在 Android 11 及更高版本
中,分区存储将是强制性的
在 Api 级别 29 中,此方法已弃用..
您无法直接访问用户的存储空间。
如果您想保存任何文件,根据您的用例,将有几种方法..
- 分区存储(其他应用无法访问)
- 使用 MediaStore(用于媒体文件)
有关详细信息,请参阅 here
我下载音乐并想在我的回收站中播放,一切正常 android 但在 android 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);
请帮帮我...
getExternalStorageDirectory
是 deprecated in Android 10, you should check out new restrictions for accessing storage called Scoped Storage。对于 Android 10,您可以选择退出并添加 requestLegacyExternalStorage
标志以显示,但在 Android 11 及更高版本
在 Api 级别 29 中,此方法已弃用.. 您无法直接访问用户的存储空间。 如果您想保存任何文件,根据您的用例,将有几种方法..
- 分区存储(其他应用无法访问)
- 使用 MediaStore(用于媒体文件)
有关详细信息,请参阅 here