Nikunj Patel
Nikunj Patel

Reputation: 22066

getApplicationContext(), getBaseContext(), getApplication(), getParent()

What is the difference between:

  1. getApplicationContext()
  2. getBasecontext()
  3. getApplication()
  4. getParent()

Can you elaborate with one simple example?

Upvotes: 98

Views: 57988

Answers (1)

Harinder
Harinder

Reputation: 11944

getApplicationContext() Application context is associated with the Application and will always be the same throughout the life cycle.

getBasecontext() should not be used, just use Context instead of it which is associated with the activity and can be destroyed when the activity is destroyed.

Upvotes: 37

Related Questions