简体   繁体   English

为什么文件访问方法 getExternalStorageDirectory() 在 Android 10 (API 29) 上不起作用

[英]why file accessing method getExternalStorageDirectory() is not working on Android 10 (API 29)

This is my code to access abc.jpg file in Music folder.这是我在 Music 文件夹中访问 abc.jpg 文件的代码。

String m=Environment.getStorageDirectory().getPath();
inputStream=cr.openInputStream(Uri.parse("file:"+Environment.getExternalStorageDirectory().getPath()+"/Music/abc.jpg"));

when i try to run this code it gives error.当我尝试运行此代码时,它会出错。

File Not Found

We have to add我们必须添加

 android:requestLegacyExternalStorage="true"

In Android Mainfest File.在 Android Mainfest 文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 android:requestLegacyExternalStorage=“true” 在 Android 10 - API 29 中不起作用 - Why android:requestLegacyExternalStorage=“true” not working in Android 10 - API 29 Android 10(api-29)文件写入 - Android 10 (api-29) file writing Android 10 (api 29) 中没有这样的文件或目录 - No such file or directory in Android 10 (api 29) 如何在 API 29 中不推荐使用 getExternalStorageDirectory 时读取或写入文件? - How to read or write file as getExternalStorageDirectory is deprecated in API 29? Webrtc Android:屏幕共享在 API 29 (Android 10) 上停止工作 - Webrtc Android: Screen Sharing stopped working on API 29 (Android 10) Android 10 (API 29) 升级后 setColor 不起作用 - setColor not working after Android 10 (API 29) upgrade boot_completed 不工作 Android 10 Q API 级别 29 - boot_completed not working on Android 10 Q API level 29 getExternalStorageDirectory 在 Android 10 中已弃用 - getExternalStorageDirectory deprecated in Android 10 重命名由应用程序在 android 10 中创建的 Mediastore 文件。在 Android API 30 上工作,但在 API 29 中显示错误 - Rename file of the Mediastore which is created by app in android 10. Working on Android API 30 but shows error in API 29 将数据附加到 android 10 (API 29) 中的文本文件 - Append data to text file in android 10 (API 29)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM