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

  • Home
  • SEARCH
  • 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 6181117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:57:50+00:00 2026-05-24T00:57:50+00:00

Scenario : I have a member variable, an array-list,(which is not static, private member)

  • 0

Scenario :

I have a member variable, an array-list,(which is not static, private member) which contains custom objects in Activity1,

I transition to Activity 2, putting activity1 in pause state.
As of now I am not saving data of array-list.

I come back from activity 2 , and activity one is in resume state.

My doubt is, do I have to save the data of array-list(member variable) in onPause() when I am moving to activity2, essentially , array-list is holding references to custom object.

Though with quick test, data of array-list is still intact, but I am doubtful whether those objects are free to be garbage collected and that I should save the data of array-list and reload it in onResume.

  • 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-24T00:57:50+00:00Added an answer on May 24, 2026 at 12:57 am

    It’s better to save your data in onPause() because this is last method that’s guaranteed to be called, after that there is no guarantees for any of the Activity’s lifecycle methods to be called. See more in “Activity Lifecycle”.

    If data in Activity member should not be persisted across process starts, you can save it in your onDestroy() too. If process is not killed, onDestroy() is also guaranteed to be called.

    But you should be aware that as soon as Activity 2 is started, Activity 1 can be destroyed at any time. So you probably need to persist you member object somehow at least in onDestroy(), and even better in your onPause(). Another thing to be aware of is configuration changes (orientation change for example). Those trigger destruction of old Activity and creation of new Activity instance. If you do not persist you member in onPause()/onDestroy() (and then restore it in onCreate()) you’ll have empty field after config change.

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

Sidebar

Related Questions

Ok, i have simple scenario: have two pages: login and welcome pages. im using
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario I have two wrappers around Microsoft Office, one for 2003 and one for
Scenario: I have a text file that has pipe (as in the | character)
Scenario: I have a document I created using LaTeX (my resume in this case),
I have the following scenario I have a main form as MDI parent and
The scenario: we have a web system that automatically generates office 2003 excel files
Here's my scenario - I have an SSIS job that depends on another prior
Here's the scenario: You have a Windows server that users remotely connect to via
Here's the scenario: I have a textbox and a button on a web page.

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.