简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM