Xamarin.android how to get Pictures path?

mc 5,511 Reputation points
2021-07-01T08:54:43.2+00:00

Android.OS.Environment.ExternalStorageDirectory.AbsolutePaht is obsolete

how to get it now?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-07-02T01:46:37.923+00:00

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.