I am trying to get the path to the private external storage directory of my c# xamarin android app. The microsoft docs tell us to use
Android.Content.Context.GetExternalFilesDir(string)
However, when I try to use this function, I get the following error regarding that function:
An object reference is required for the non-static field, method or property
This is my code
class RecorderController {
string externalStoragePath;
public RecorderController() {
externalStoragePath = Path.Combine(Context.GetExternalFilesDir(null), "recordings");
// I have also tried the following:
// string s = null;
// externalStoragePath = Path.Combine(Context.GetExternalFilesDir(s), "recordings");
// Even when I try to get the path to the Downloads folder, I get the same error:
// string s = Android.OS.Environment.DirectoryDownloads;
// externalStoragePath = Path.Combine(Context.GetExternalFilesDir(s), "recordings");
}
}
I have no clue how to solve this, does anybody know what I am doing wrong?