How to initialize context?

android, android-context

Solution

You cannot instantiate a Context object. This is controlled by the system. However, every Application has a Context and every Activity is a Context, so you have a couple of was to obtain a pointer to a Context object:

Assign a pointer to an Activity object to the Context object pointer (i.e. Using the this keyword)

The Activity class has a method called getApplicationContext() which retrieves a pointer to the Context object contained by the Application.

Problem

This is a really stupid question but what do I set context equal to in Context context = ... Just declaring it sets it to null and I need to use context for my app.

Original source