Context
to use?SOURCE: StackOverflow, Dave Smith
In most cases, use the Context
directly available to you from the enclosing component you’re working within.
You can safely hold a reference to it as long as that reference does not extend beyond the lifecycle of that component. As soon as you need to save a reference to a Context
from an object that lives beyond your Activity
or Service
, even temporarily, switch that reference you save over to the application context.
For more details, read those two sources.