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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:52:38+00:00 2026-06-12T14:52:38+00:00

I am trying to save values entered to a form so that when a

  • 0

I am trying to save values entered to a form so that when a user returns to the activity the content entered remains populated. As it functions now. The user can enter details and click the “send button”. The the next activity will then show details of what the user entered. If the user selects the “back button”, the user returns the previous activity but the content is wiped from the fields in the form. Any suggestions would be appreciated.

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {
     public final static String EXTRA_FROM = "com.example.assignment1.FROM";
     public final static String EXTRA_TO = "com.example.assignment1.TO";
     public final static String EXTRA_CC = "com.example.assignment1.CC";
     public final static String EXTRA_SUBJECT = "com.example.assignment1.SUBJECT";
     public final static String EXTRA_COMPOSE = "com.example.assignment1.COMPOSE";



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    @Override
    protected void onSaveInstanceState(Bundle outState)
    {
        super.onSaveInstanceState(outState);
        EditText emailFrom =(EditText) findViewById(R.id.editEmailFrom);
        String from = emailFrom.getText().toString();
        outState.putString(EXTRA_FROM, from);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedState)
    {
        EditText emailFrom =(EditText) findViewById(R.id.editEmailFrom);
        String from = savedState.getString(EXTRA_FROM);
        emailFrom.setText(from);
    }
    public void emailSend (View sendButton) 
    {
        Intent intent = new Intent(this,DisplayEmailActivity.class);
        EditText emailFrom =(EditText) findViewById(R.id.editEmailFrom);
        EditText emailTo =(EditText) findViewById(R.id.editEmailTo);
        EditText emailCc =(EditText) findViewById(R.id.editEmailCc);
        EditText emailSubject =(EditText) findViewById(R.id.editEmailSubject);
        EditText emailCompose =(EditText) findViewById(R.id.editEmailCompose);

        String from = emailFrom.getText().toString();
        String to = emailTo.getText().toString();
        String cc = emailCc.getText().toString();
        String subject = emailSubject.getText().toString();
        String compose = emailCompose.getText().toString();

        intent.putExtra(EXTRA_FROM,from);
        intent.putExtra(EXTRA_TO,to);
        intent.putExtra(EXTRA_CC,cc);
        intent.putExtra(EXTRA_SUBJECT,subject);
        intent.putExtra(EXTRA_COMPOSE,compose);

        startActivity(intent);
    }



    public void emailClear (View clearButton) {
         ((EditText) findViewById(R.id.editEmailFrom)).setText("");
         ((EditText) findViewById(R.id.editEmailTo)).setText("");
         ((EditText) findViewById(R.id.editEmailCc)).setText("");
         ((EditText) findViewById(R.id.editEmailBcc)).setText("");
         ((EditText) findViewById(R.id.editEmailSubject)).setText("");
         ((EditText) findViewById(R.id.editEmailCompose)).setText("");  
    }

}

Second Activity……

public class DisplayEmailActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_email);

        Intent intent = getIntent();

        String from = intent.getStringExtra(MainActivity.EXTRA_FROM);
        String to = intent.getStringExtra(MainActivity.EXTRA_TO);
        String cc = intent.getStringExtra(MainActivity.EXTRA_CC);
        String subject = intent.getStringExtra(MainActivity.EXTRA_SUBJECT);
        String compose = intent.getStringExtra(MainActivity.EXTRA_COMPOSE);


        TextView textFrom =(TextView)findViewById(R.id.displayEmailFrom);
        TextView textTo =(TextView)findViewById(R.id.displayEmailTo);
        TextView textCc =(TextView)findViewById(R.id.displayEmailCc);
        TextView textSubject =(TextView)findViewById(R.id.displayEmailSubject);
        TextView textCompose =(TextView)findViewById(R.id.displayEmailCompose);

        textFrom.setText(from);
        textTo.setText(to);
        textCc.setText(cc);
        textSubject.setText(subject);
        textCompose.setText(compose);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_display_email, menu);
        return true;
    }

    public void emailBack (View backButton){
        Intent intent = new Intent(this,MainActivity.class);

        startActivity (intent);
    }


}
  • 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-12T14:52:39+00:00Added an answer on June 12, 2026 at 2:52 pm

    Replace the method like this,

    public void emailBack (View backButton){
    
        onBackPressed();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to save (RavenDB build 960) the names and values of form
I am still trying to save a user email entered in options.html to the
I'm trying to save some values from a form in CakePHP into a MySQL
I'm trying to save two user values (SliderWidth and SliderHeight). I want to do
Hi I am trying to use NSUserDefaults to save some default values in database.
When trying to save the database using boost serialization, I encounter the segfault that
I'm trying to save my Photo class that has a byte[] File field. When
Thank you for reading. I'm trying to create a HTML form so that my
I'm trying to implement some pixel tracking where I will save certain values in
I'm trying to save dynamic html so that on a failed validation in asp.

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.