Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8052415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:32:27+00:00 2026-06-05T07:32:27+00:00

I have a public variable set in my Main Activity that declares the App

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:32:28+00:00Added an answer on June 5, 2026 at 7:32 am

    You should use some sort of persistent storage, SharedPreferences seem like a good option for the task at hand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a public variable testStr in my applications main form. I have a
I have an android app that is setup to start a Java activity (call
I have an Android app with a main tab activity, and several activities within
I have already set a variable in my document class Main.as. I am now
My problem is that I have to set a variable in a try statement
WorkAround: I have declared a class level Public static variable and initialized with a
I have a class level price variable decalred inside a page, like this: public
I have a static method which sets a variable: static String[] playersNames; public static
I have public and private keys in separate .pem files that I would need
Is it possible to have final transient fields that are set to any non-default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.