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 9304217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:39:42+00:00 2026-06-18T23:39:42+00:00

In my Android app I have set a custom Application-derived class. In it I

  • 0

In my Android app I have set a custom Application-derived class. In it I have a member field to store some arbitrary object in.

So I have:

public class MyApp extends Application {

public static MyApp mInstance;
public Object mData;

@Override
public void onCreate() {
   mInstance = this;
}

public void setData(Object data) {
    mData = data;
}

public Object getData() { return mData; } 

}

Now in one Activity I’m doing

public doSetData() {

     someMyData = ....
     MyApp.mInstance.setData(someMyData);

}

In another Activity I’m doing

@Override
public void onCreate(Bundle) {

     Object myDataRetrieved = MyApp.mInstance.getData();

}

I can see that sometimes myDataRetrieved is null. However, I believe I have never passed null in MyApp.setData(). Of course, I can be wrong.

Yet, can there be such circumstances under which MyApp.mData becomes null by itself?

  • 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-18T23:39:42+00:00Added an answer on June 18, 2026 at 11:39 pm

    Yet, can there be such circumstances under which MyApp.mData becomes null by itself?

    Sure. It will happen every time Android terminates the process, which will happen when your app is not in the foreground, Android needs RAM, and your app is next in line to be terminated.

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

Sidebar

Related Questions

I have an Android app that begins by displaying a dialog. When I set
I am coding a custom lockscreen app for android. I have managed to disable
I have an android app that register a custom url scheme (let's say app://)
I repair big android app and I have many custom dialogs which inherit from
For an Android app...I have a button on an Activity that calls a custom
How to set custom time to Android AnalogClock placed in app widget? As an
I have a simple android application which does search. I have a custom popup
I'm working on an application which uses SQLite Database on Android.I have a custom
I am creating an Android app, and I have a button with a custom
I have a working android app using TextView, some formatting (line breaks, rows of

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.