What are the essential differences between getContext () methods,
getApplicationContext () , getBaseContext () , and this to get the
Context in Android?
Returns the context in which the view is executed, usually the Activity, through this context you can access the current theme, resources, etc.
Returns the context of the single global Application object of the current process. By using this context you ensure that you have a context tied to the life cycle of the application. You could say that it is the most "light" context.
getBaseContext () :
The base context set by the constructor or setBaseContext.
To talk about this context it is necessary to talk about ContextWrapper which is a class by means of which You can access one context within another. The context referenced by ContextWrapper is obtained through getBaseContext () . Obtaining the context using this method is related to that of the Activity.
This reference can be used in an Activity since Activity inherits from
Context and is the reference to the context of the Activity: