# How to Fix cannot resolve symbol ‘context’ in Java Android

This is a common error when you  use context as a variable but you haven’t initialized and declared it

for example, take a look at this screenshot. here is an AlertDialog showing the error in context (red color).

### How to fix this error?

to fix this, use this simple code

`final Context context = this;`

This should fix the context because we now have declared it, let’s see the screenshot

Sometimes, the getBaseContext(),getApplicationContext() etc may also work instead of context, but not in every case, it depends on the code