lundi 9 mai 2016

Update sqlite not working on android

I have a login and reset password activity. When I enter the new updated password and try to login again, I cannot do so with the new password. Logging in with the old password works fine. Basically, the password field is not getting updated/overwritten.

There is no error in the logcat. Just that the password is not updated.

Please help as I am new to android development.

Code for update( DataRegister is the class with GET AND SET functions):

public int updatePassword(DataRegister dataregister) {

db = dbHelper.getWritableDatabase();
ContentValues updated = new ContentValues();
updated.put("PASSWORD", dataregister.getPASSWORD());

return db.update(DataRegister.TABLE, updated, "EMAIL=?" , new String[]   {dataregister.getEMAIL()});


Code for retrieval:

public String getPass(DataRegister dataRegister) {

db = dbHelper.getWritableDatabase();

Cursor cursor = db.query(DataRegister.TABLE, null, "EMAIL=?",
        new String[]{dataRegister.getEMAIL()}, null, null, null, null);
if (cursor != null && cursor.moveToFirst())

    pass = cursor.getString(cursor.getColumnIndex("PASSWORD"));
return pass;

// return contact


Code for Login:

  String email = editTextUserName.getText().toString();

        String password = editTextPassword.getText().toString();

        String storedPassword = loginDataBaseAdapter.getSinlgeEntry(dataRegister);

        Toast.makeText(Login.this, storedPassword,Toast.LENGTH_LONG).show();
        Boolean a=loginDataBaseAdapter.isExist(dataRegister.getEMAIL());
       validation = getSharedPreferences("myShaPreferences", Context.MODE_PRIVATE);

        if (password.equals(storedPassword)) {

                    "Congrats: Login Successful", Toast.LENGTH_LONG)

        else {

                        "User Name or Password does not match",



Code for reset password:

public class ResetPassword extends AppCompatActivity {

 protected void onCreate(Bundle savedInstanceState) {

 email = (EditText) findViewById(;
 dataRegister=new DataRegister();

loginDataBaseAdapter = new DatabaseAdapter(this);
loginDataBaseAdapter =;

pass = (EditText) findViewById(;
conpass = (EditText) findViewById(;

email1 = email.getText().toString();
pass1 = pass.getText().toString();

conpass1 = conpass.getText().toString();

Button btnReset = (Button) findViewById(;
btnReset.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {

        if (pass1.equals(conpass1)) {

            String newpass =loginDataBaseAdapter.getPass(dataRegister);

Aucun commentaire:

Enregistrer un commentaire