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

The Archive Base Latest Questions

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

i am validation of login page is done by server side.i create one checkbox

  • 0

i am validation of login page is done by server side.i create one checkbox for remember username and password.if check box is checked it remembers the username and password.But the problem is even if check box unchecked also it finds stored username and password. now i want if checkbox is unchecked means it cannot remember username and password

 i try this code
   public class Login extends Activity {
  SharedPreferences app_preferences ;
CheckBox check;


private static final String UPDATE_URL = "serverurl";

public ProgressDialog progressDialog;

private EditText UserEditText;

private EditText PassEditText;



public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);


    app_preferences = PreferenceManager.getDefaultSharedPreferences(this);
    progressDialog = new ProgressDialog(this);

    progressDialog.setMessage("Please wait...");

    progressDialog.setIndeterminate(true);

    progressDialog.setCancelable(false);



    UserEditText = (EditText) findViewById(R.id.username);

    PassEditText = (EditText) findViewById(R.id.password);
    check=(CheckBox) findViewById(R.id.checkbox);
    String Str_user = app_preferences.getString("username","0" );
    String Str_pass = app_preferences.getString("password", "0");
    String Str_check = app_preferences.getString("checked", "no");
    if(Str_check.equals("yes"))
    {
            UserEditText.setText(Str_user);
           PassEditText.setText(Str_pass);
            check.setChecked(true);
    }
    Button button = (Button) findViewById(R.id.okbutton);

    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            int usersize = UserEditText.getText().length();

            int passsize = PassEditText.getText().length();

            if(usersize > 0 && passsize > 0) {

                progressDialog.show();

                String user = UserEditText.getText().toString();

                String pass = PassEditText.getText().toString();
                String Str_check2 = app_preferences.getString("checked", "no");
                if(Str_check2.equals("yes"))
                {
                    SharedPreferences.Editor editor = app_preferences.edit();
                    editor.putString("username", user);
                    editor.putString("password", pass);
                     editor.commit();
                }

                doLogin(user, pass);

            } else createDialog("Error","Please enter Username and Password");

        }

    });

   check box
    check.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                // Perform action on clicks, depending on whether it's now checked
                SharedPreferences.Editor editor = app_preferences.edit();
                if (((CheckBox) v).isChecked())
                {

                     editor.putString("checked", "yes");
                     editor.commit();
                }
                else
                {
                     editor.putString("checked", "no");
                     editor.commit();
                }
            }
        });
  • 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-02T11:34:52+00:00Added an answer on June 2, 2026 at 11:34 am

    try

     String Str_check = app_preferences.getString("checked", "no");
        if(Str_check.equals("yes"))
        {
    String Str_user = app_preferences.getString("username","0" );
        String Str_pass = app_preferences.getString("password", "0");
    
                UserEditText.setText(Str_user);
               PassEditText.setText(Str_pass);
                check.setChecked(true);
        }
    else{
       SharedPreferences.Editor editor = app_preferences.edit();
                        editor.putString("username", "");
                        editor.putString("password", "");
                         editor.commit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating registration page and I've done basic client side (JS) form validation. Now
I have a Registaration page with the following fields Email, Confirm Email, Password and
For the login page of my website I would like to list the latest
I've heard (on a podcast) about using Silverlight to do client-side validation on an
I am writing a password-reset page for my website. Here's my idea: a. User
Take a look at this login page , specifically, the form in the section
I'm trying to make a login page in Struts. The idea is to validate
I have been looking at either coding from scratch a basic login page +
I have this login page as the second page of my application. there are
I have a registration page and would like to perform some validation (in addition

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.