I do not fully understand the problem with a memory leak due to the transfer of context to static methods. I understand that there is no universal advice and you need to look at the code, but can anyone give a link to a clear explanation.
For example, I have a Singleton DB class where I need to pass context every time.
public DB(Context ctx) { mCtx = ctx; } So this is why the following is not taken:
public class AppContext { private static Context sContext; private static Application sApplication; public static Context getContext() { return sContext; } public static void setContext(Context context) { sContext = context; } public static Application getApplication() { return sApplication; } public static void setApplication(Application application) { sApplication = application; } } And in the main activation, perform setContext and setApplication and then use AppContext.getApplication () in DB instead of passing the context each time?