I am working in remember me
function in android where i have stored the username and password in storage class,the storage
class is the class where i implement the Shared preferences.
What i have done
First i am checking that if the checkbox is checked or not if ischecked then i store the value in storage class(shared preferences).and in login service i am calling the username with password.
Here is the code:
Inside OnCreate
boolean isChecked = true;
login_submit_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
LoginService();
}
});
chkRememberMe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
storage.saveUserName(Login.this, mUserName);
storage.savepass(Login.this, mPassword);
}
}
});
}
outside:
protected void LoginService() {
// TODO Auto-generated method stub
mUserName = login_email_edit.getText().toString().trim();
mPassword = login_password_edit.getText().toString().trim();
if (chkRememberMe.isChecked()) {
mUserName=storage.getUserName(Login.this);
mPassword=storage.getpass(Login.this);
}
if (mUserName.length() == 0) {
AlertDialog(" Enter Email ", Login.this);
} else if (isContainsEmpty(mUserName)) {
login_submit_btn.setEnabled(true);
AlertDialog("Valid Email Address", Login.this);
}
else if(mPassword.length() == 0){
AlertDialog("Password should not be blank", Login.this);
}
}
Can anybody figure out my mistake .@Thanks