Android Studio - How to use getExternalFilesDir

Viewed 5018

Since google killed the perfectly fine method getExternalStoragePublicDirectory, I have to try to get getExternalFilesDir to work.

This is one of the things I've tried:

private Context context = this.getApplicationContext();
private static final String test = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);

error message:

Non-static field 'context' cannot be referenced from a static context

I am not allowed to make context a static field though.

1 Answers

what is this reference to your activity, if yes then use:

this.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
Related