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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:51:30+00:00 2026-06-02T15:51:30+00:00

This is my code. I would like to save my strings into the shared

  • 0

This is my code. I would like to save my strings into the shared preference.

private String sla;
private String b;
private String c;
//EditText aa=(EditText)findViewById(R.id.et1);
EditText aa2=(EditText)findViewById(R.id.et2);
EditText aa3=(EditText)findViewById(R.id.et3);
SharedPreferences settings = getSharedPreferences ("PREF_DEMO", 0);

 /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.setup);

         RadioGroup rdg=(RadioGroup)findViewById(R.id.ragp);

         rdg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                public void onCheckedChanged(RadioGroup group, final int checkedId) {
                    switch (checkedId) {
                        case R.id.radio0:
                            sla = "au";
                            Toast.makeText(group.getContext(), "Auto", Toast.LENGTH_LONG).show();
                            break;
                        case R.id.radio1:
                             sla = "ma";
                             Toast.makeText(group.getContext(), "Manual", Toast.LENGTH_LONG).show();
                            break;
                        }
                };
            });
         final Button set = (Button) findViewById(R.id.nn);
         set.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 // Perform action on click
                // a=aa.getText().toString();
                 b=aa2.getText().toString();
                 c=aa3.getText().toString();
                 SharedPreferences.Editor editor = settings.edit();

                 editor.putString("sp", b);
                 editor.putString("tp", c);
                 editor.putString("op", sla);
                 editor.commit();
                 Toast.makeText(v.getContext(), "saved", Toast.LENGTH_LONG).show();
             }
         });

So, I got an exception from the logcat telling error on line “EditText aa3=(EditText)findViewById(R.id.et3);”
There is no parsing error in this code.

  • 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-02T15:51:32+00:00Added an answer on June 2, 2026 at 3:51 pm

    after setContentView(R.layout.main) add this line Because before cant get refrence from layout xml file

      EditText aa2=(EditText)findViewById(R.id.et2); 
      EditText aa3=(EditText)findViewById(R.id.et3);
    

    add like….

      EditText aa2;
      EditText aa3;
    
     public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.setup);
    
             aa2=(EditText)findViewById(R.id.et2);
             aa3=(EditText)findViewById(R.id.et3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I would like to share code between multiple assemblies. This shared code will
I would like to see how this example of existing code would be able
I would like to ask you about some advices about this code. It works,
I have this code and don't know if what I would like to achieve
Is this code correct? I'm trying to submit it and also I would like
i have this code, and need help with the logic end. I would like
I have this source code from 2001 that I would like to compile. It
In this C# code snippet, DateTime.Now.Month.ToString() returns 7 as output. I would like to
I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I would like to maintain a list of all of the strings entered into

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.