Reputation: 5899
I have a public variable set in my Main Activity that declares the App as the free version or paid (boolean).
I am receiving a lot of crash errors (null pointer exceptions) when it is accessed from a separate activity. I can't reproduce this error on test devices so I can only assume that Android loses the Main Activity Variable when it is low on memory?
Typically this happens when my users navigate to the browser to download a file and then navigate back to my App.
Should I be setting a variable local to the Activity so it no longer references a separate Activity? Or is there a way to keep that variable in memory?
Upvotes: 0
Views: 59
Reputation: 46856
You should use some sort of persistent storage, SharedPreferences seem like a good option for the task at hand.
Upvotes: 2