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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:43:52+00:00 2026-05-13T10:43:52+00:00

I am creating event search application, we set search criteria from one screen populate

  • 0

I am creating event search application, we set search criteria from one screen populate in another screen then user can edit search criteria from 3rd screen and goes to 4th screen.

To achieve above task i am using static object which remember the values around the application and i don’t need to do any thing extra.

But i am afraid if about static object life cycle in android if low memory found android delete static objects ???

As android supports multi tasking, if user switches to another application and when user comes back application start acting crazy, does static object get removed when it multi task ??? any idea ?? and also suggest holding static object via singleton method is better approach ???

  • 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-05-13T10:43:52+00:00Added an answer on May 13, 2026 at 10:43 am

    Lets start with a bit of background: What happens when you start an application?
    The OS starts a process and assigns it a unique process id and allocates a process table.A process start an instance of DVM(Dalvik VM); Each application runs inside a DVM.
    A DVM manages class loading unloading, instance lifecycle, GC etc.

    Lifetime of a static variable: A static variable comes into existence when a class is loaded by the JVM and dies when the class is unloaded.

    So if you create an android application and initialize a static variable, it will remain in the JVM until one of the following happens:

    1. the class is unloaded
    2. the JVM shuts down
    3. the process dies

    Note that the value of the static variable will persist when you switch to a different activity of another application and none of the above three happens. Should any of the above three happen the static will lose its value.

    You can test this with a few lines of code:

    1. print the uninitialized static in onCreate of your activity -> should print null
    2. initialize the static. print it -> value would be non null
    3. Hit the back button and go to home screen. Note: Home screen is another activity.
    4. Launch your activity again -> the static variable will be non-null
    5. Kill your application process from DDMS(stop button in the devices window).
    6. Restart your activity -> the static will have null value.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Java application where the user can search through a list of
When creating a web application, and lets say you have a User object denoting
I am having difficulty reliably creating / removing event sources during the installation of
I'm creating an installer for a website that uses a custom event log source.
In a page, on the load event, I am dynamically creating controls for display
I'm creating an application which lets you define events with a time frame. I
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
I'm replacing an old web application with a new one, with different structure. I
I'm writing an application for Mac OS X 10.6 and later in C++. One
Outline My simple application takes text from a text box and calls an asp.net

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.