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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:45:15+00:00 2026-06-06T08:45:15+00:00

My application has two layouts A and B. In A a user chooses some

  • 0

My application has two layouts A and B.

In A a user chooses some data by pressing RADIO BUTTONS. Then he presses a BUTTON to go to the B layout and use this selected variables to dynamically build some views (EditTexts, TextVies, and Buttons).

In layout A i implemented onDestroy() (same thing happens if i implement onStop()) to save user selected data. If i exit the app by back or by pressing down home and removing it from task manager, the user selected data will still be visible if the user starts the application again.

Now, in layout B, first i build first part of views based on layout A’s user selected data, then i also have extra Buttons that allow a user to add and remove as many view to that layout as he/she needs.

NOW HERE COMES MY CONFUSION……………….
After the user fills out whatever is needed in layout B, then goes back to A, or exits the app, I WANT TO SAVE THAT DATA ENTERED IN LAYOUT B. I know how to save the data using SharedPreferences BUT i do not know which methods i need to implement for layout B or maybe even additionally for A to accomplish my mission.

THIS IS EXACTLY WHAT I WANT TO HAPPEN…..
All i want is to be able to start the app with user’s filled data for layout B. Layout A seems to be working. IF USER SELECTS SAME DATA IN LAYOUT A (meaning leaving everything the way it is), only then i want to use saved data, otherwise i want to restart new layout B with user’s new selections.

One more problem. If user goes back to layout A from B, since everything was saved in layout A already he can press a button and come back to layout B (maybe wants to change his/her selected values or just accidentally pressed back button). I implemented onDestroy() for layout B as well but i have a problem with it. If user does not change the selections in layout A and goes to layout B again, everything that i saved is rebuilt now, but if he/she goes back to A and comes to B again, it is not there, this keeps happening every time… If i go back and forth i will see the saved data only on odd occasions, on even occasions it is not there.

In layout B i saved everything in onDestroy(), then onCreate() i check whether layout A’s data is the same so i can rebuild the layout B again; otherwise, layout B will be new.

  • 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-06T08:45:17+00:00Added an answer on June 6, 2026 at 8:45 am

    Instead of using onDestroy()/onCreate() you’d better use onPause()/onResume(), because these are always called, but a call to onDestroy() might be missed here and there.

    You would need to implement onPause() in both your Activities, A and B.

    Once you’ve figured out how to reliably save your preferences in onPause(), you may proceed with the discarding saved data when you don’t need it according to your application logic.

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

Sidebar

Related Questions

In main.xml, I have a table layout that it has two buttons in the
The code below plots some simple x-y data, but it has two problems that
My application has two node types: a parent node which can hold recursive child
I have an application that has two threads. The first one (the main thread)
I'm trying to build an iPhone application that has two subviews in the main
I would like to create a UIBarButtonItem on my iPhone application which has two
I am working on a simple app tab-bar based application that has two views.
I am building a web application using ASP.NET MVC that has two very distinct
In my tennis application, my 'match' table has two players (obviously). I've used player1_id
An application I have recently started work on has to register two dll's, because

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.