Is it bad practice to pass the Context to a constructor and save it as a private variable for internal use? The other option is to pass the Context as a parameter to methods that need it.
Which is a better option? I have a feeling that passing to the constructor might result in memory leaks accidentally.
Often, all you need is the ApplicationContext
, so what you can do is pass this.getApplicationContext()
instead of just this
. Your app context exists for the lifetime of the app anyway, so it's not a memory leak.