Take the 2-minute tour ×

I am new to Android development and Software development too. I keep seeing this term called - 'context' in Android code. I know that it's a class in android.content package, but I don't understand what exactly is it and why is it needed in so many places, especially in the constructors.

Can someone please explain this term to me.


share|improve this question
possible duplicate of Please explain me Context class in Android –  Mat Jul 14 '11 at 5:09
add comment

1 Answer



Typical use of context:

Creating New objects: Creating new views, adapters, listeners:

TextView tv = new TextView(getContext()); ListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(),..);

Accessing Standard Common Resources: Services like LAYOUT_INFLATER_SERVICE, SharedPreferences:

getApplicationContext().getSharedPreferences(name, mode);

Accessing Components Implicitly: Regarding content providers, broadcasts, intent


Its copy from here

share|improve this answer
add comment

Your Answer


