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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:30:13+00:00 2026-05-24T06:30:13+00:00

I have 2 activitys, one is where the user can update or set a

  • 0

I have 2 activitys, one is where the user can update or set a new password via edittext boxes, called Password and the other activity is a login screen where they have to enter their password and then it validates using sharedpreferences, called LogIn. The Password activity works fine. I can update or set new passwords no problem but the Login activity isn’t comparing to the users inputed value. In short after they set their password up when they go to login using their password it says password is incorrect which its not. I have posted both activitys.

public class Password extends Activity implements View.OnClickListener{


public static final String PASSWORD_PREF_KEY ="passwd";

private TextView messages;
private EditText pass1;
private EditText pass2;
Button button1, button2;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.mainin);

    messages = (TextView) findViewById (R.id.text1);
    pass1 = (EditText) findViewById(R.id.password);
    pass2 = (EditText) findViewById (R.id.password_confirm);

    button1 = (Button) findViewById(R.id.ok);
    button2 = (Button) findViewById(R.id.button1);

    button1.setOnClickListener(this);
    button2.setOnClickListener(this); }


    public void onClick(View v){
        switch(v.getId()){
        case R.id.button1:
            startActivity(new Intent(Password.this,LogIn.class));  finish(); 
        case R.id.ok:
        String p1 = pass1.getText().toString();
        String p2 = pass2.getText().toString();

        if (p1.equals(p2)) {
            if (p1.length() >=6 || p2.length() >=6) {

                SharedPreferences settings = getSharedPreferences(Password.PASSWORD_PREF_KEY,0);
                SharedPreferences.Editor editor = settings.edit();   

                editor.putBoolean(Password.PASSWORD_PREF_KEY,true);    


                editor.commit();
                messages.setText("Password updated!");
            }
            else
                messages.setText("Passwords must be at least 6 characters");
        }
        else{
            pass1.setText("");
            pass2.setText("");
            messages.setText("Passwords do not match");
            }
        }
};      

public class LogIn extends Activity {

private EditText pass1;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.password);

    pass1 = (EditText) findViewById(R.id.et_pw);

   SharedPreferences passwd =  getSharedPreferences(Password.PASSWORD_PREF_KEY,0);
   final String p3 = passwd.getString(Password.PASSWORD_PREF_KEY,null);
    final String p1 = pass1.getText().toString(); 

    Button page1 = (Button) findViewById(R.id.btn_login); 
    page1.setOnClickListener(new View.OnClickListener() {         
        public void onClick(View view) { 
            if (p3.equals(p1)) {     
                startActivity(new Intent(LogIn.this,Main.class));  
                 } 
            else {     
                Toast.makeText(getApplicationContext(),"Incorrect Password",Toast.LENGTH_LONG).show();
                }
            };
            });
  };
    }
  • 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-24T06:30:15+00:00Added an answer on May 24, 2026 at 6:30 am

    It looks like you are putting a boolean of true into the shared preferences instead of putting the password string. so when you compare the edit text string with the shared preference they are not going to equal each other.

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

Sidebar

Related Questions

I have an Activity in which user can update a specific information clicking in
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have developing an App where the user can create event and set notification
I have to include one report in my application showing offline/online activity of few
I have an activity that has a TabHost containing a set of TabSpecs each
I have an Activity in Android, with two elements: EditText ListView When my Activity
In my application, I have 2 list activities which can start one or the
I have one Application which has more then 5 Activity I want to know
Here's scenario: I have 2 activities and one service First activity is a landing
There are several packages in my application that user can select each one according

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.