question

6666666 avatar image
0 Votes"
6666666 asked LeonLu-MSFT commented

Xamarin.android how to get Pictures path?

Android.OS.Environment.ExternalStorageDirectory.AbsolutePaht is obsolete

how to get it now?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LeonLu-MSFT avatar image
0 Votes"
LeonLu-MSFT answered LeonLu-MSFT commented

Hello,​

Welcome to our Microsoft Q&A platform!

You can use Application.Context.GetExternalFilesDir();, Application.Context.GetExternalCacheDirs(); Application.Context.GetExternalMediaDirs(); But three method store file in your application folder /storage/emulated/0/Android/data/com.companyname.xxx/cache , it will not store file to the external folder path.

Here is similar thread:

https://stackoverflow.com/a/57116787/10627299

Note: If your targetSdkVersion is below 30 and want to store file to external public folder, using android:requestLegacyExternalStorage="true" in the <application> element of the manifest. This is not a long-term solution, as your targetSdkVersion will need to be 30 or higher, due to the Android 11’s limitation of storage, we have to store file to the application folder /storage/emulated/0/Android/data/com.companyname.xxx/, so store the file to internal path with var InternalPath= Android.App.Application.Context.GetExternalFilesDir("").AbsolutePath; is a suitable way.
`

Best Regards,

Leon Lu



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If you want to get Image from DCIM, you can use ContentResolver to get it .please refer to this thread: https://stackoverflow.com/a/57649669/10627299

0 Votes 0 ·