Xamarin Android get privateExternalStorage with GetExternalFilesDir()

Viewed 2043

I have an app that needs to create a file in an app-specific directory, but that file need to be public so it can be edited by another app, so I need a path like this "/storage/emulated/0/Android/data/com.my.app/files"

I already checked Xamarin Documentation and I found what I need. Based on that Documentation I can use this method Android.Content.Context.GetExternalFilesDir(string type).

But I get this error when I call that method.

An object reference is required for the non-static field, method, or property 'Context.GetExternalFilesDir(string)'

I also already check this forum but found no luck

Any ideas how to solve this issue ?

1 Answers

To get privateExternalStorage you can use this

Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;

Related