I'm trying to create a function which will update the password in the database. The function itself returns true value, however the data is not updated and remains the same. Also I changed the result of that long value and it returns 0. I'll very grateful for some suggestions on how to make it work correctly. Here's the code of the function:
public Boolean changePassword(String name, String email, String password) {
SQLiteDatabase DB = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("name", name);
contentValues.put("email", email);
contentValues.put("password", password);
Cursor cursor = DB.rawQuery("Select * from UserDetails where name = ? and email = ?", new String [] {name,email});
if(cursor.getCount()>0) {
long result = DB.update("UserDetails", contentValues, "password = ?", new String[] { password });
System.out.println("Result= "+result);
if (result == -1)
return false;
else
return true;
} else
return false;
}