How do you fix non-static method cannot be referenced from a static context?
There is one simple way of solving the non-static variable cannot be referenced from a static context error. Address the non-static variable with the object name. In a simple way, we have to create an object of the class to refer to a non-static variable from a static context.
How do you get the context of a static method?
You can use the following: MainActivity. this. getApplicationContext();