I'm fairly new to android and having an issue grasping the concept of Contexts and all.
I have a small app that consists of 3 activities:
1- Main Activity
2- Login Activity
3- Splash Activity
I've created a number of classes that are part of MainActivity and run as part of it. One of the classes is a database helper. Database helper needs a context to use and what I do is, in MainActivity:
public static Context context;
and in onResume I do:
@Override
public void onResume() {
super.onResume();
this.context = this;
}
All activities work just fine, spalsh works, login works, everything works fine. I've defined everything in Manifest.
But randomly when I leave my app running in background for a while and do other stuff with my phone and open it up, sometimes it just crashes pointing to a function that gets "context" as an argument.
Is there anything I can do to fix this?
Thanks