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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:25:46+00:00 2026-06-16T13:25:46+00:00

I have Android application and own Application derived class holding some internal data. Among

  • 0

I have Android application and own Application derived class holding some internal data.
Among other there are some string fields. The problem is that if I put the application in foreground, work on other application, switch back to my app again, the app may be restarted because it got killed by system. Unfortunatelly the Application object seems not to be created again because the onCreate method of application object doesn’t get called and all fields are set to null. My Activity gets recreated but all Application’s object fields are null. When is the Application.onCreate method called? How to handle it?

  • 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-16T13:25:47+00:00Added an answer on June 16, 2026 at 1:25 pm

    there is no onCreate that you can register to.
    in later API’s there’s a way to register to the Activity lifecycle functions. and then you can do what ever you want.

    basically, what you should do is use SharedPrefrences for storing information.

    what I would do is:

    class MyApp extends Application {
        private static String someResource = null;
        public static String getSomeResource(Context context) {
           if(someResource == null) {
               SharedPrefrences prefs = (SharedPrefrences)
                      context.getSystemService(Context.SHARED_PREFRENCES);
               someResource = prefs.getString(SOME_RESOURCE, null);
           }
        return someResource;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Android application I have an Observable Data class, which contains a method
I want to have my own Launcher Application for Android in other words ,
I have an android application. There are a lot of buttons in it but
I have an android application in which I have to execute some tasks at
I have android application with ListView, where each row has own refresh button. Refreshing
I have my own Android Application, I named it SMS App and I want
In my Android application I have created an SVG image converter class. It parses
I have a simple Android application that uses an instance of a class, let's
In my Android application, I have a DefaultApplication class which extends android.app.Application , and
In my Android application, I have a simple list view with adapter. There's a

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.