theerrormagnet
theerrormagnet

Reputation: 314

Android Studio - How to use getExternalFilesDir

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.

Upvotes: 5

Views: 12707

Answers (1)

Krishna Sony
Krishna Sony

Reputation: 1369

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

this.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);

Upvotes: 4

Related Questions