I'm very new to android , this project involves Registration as the first step which takes the username and password from the user and the next activity requires a login inorder to proceed. The login is required to validate the username and password. I am unable to get the Username which is the first field in the table and the last field password.
log.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
un = user.getText().toString();
pw = pass.getText().toString();
Record rec = new Record(MainActivity.this);
SQLiteDatabase sqldb = rec.getReadableDatabase();
Cursor c = sqldb.query(Record.tbname, null,
null, null, null, null, null);
while(c.moveToNext())
{
username = c.getString(0);
password = c.getString(3);
}
if(un == username && pw == password)
{
Toast.makeText(MainActivity.this, "Valid Credentials", Toast.LENGTH_LONG).show();
Intent next = new Intent();
next.setClass(MainActivity.this, HomeActivity.class);
startActivity(next);
}
else
{
Toast.makeText(MainActivity.this, "Invalid Credentials", Toast.LENGTH_LONG).show();
}
}
});
I'm cannot fetch values in order to validate the login details.