Cannot resolve symbol ‘context’

You need to do some basic Java programming tutorials. Java is totally different to JavaScript.

Here, you use context as a variable but you have neither declared it, or initialised it, hence the error.

You could define it (and initialise at the same time)

 Context context = this;

since this refers to the current object instance of a class and Activity is a Context, or more precisely, it extends Context.

Alternatively, you could just use this.

File f = File(UploadToServer.this.getCacheDir(), "filename");

Leave a Comment