Heres the code that i am using
public void onClick(View v)
{
// TODO Auto-generated method stub
if (v == btnAdd)
{
try
{
NewAccount account = new NewAccount();
account.setFacultyID(saveFacultyID.getText().toString());
account.setFname(saveFname.getText().toString());
account.setLname(saveLname.getText().toString());
account.setPassword(savePassword.getText().toString());
account.setRetype(saveRetype.getText().toString());
db.AddTeacher(account);
Toast toast = Toast.makeText(this, "New Record Saved", Toast.LENGTH_SHORT);
toast.show();
}catch(Exception e)
{
if((saveFacultyID.getText() ==null) ||
(saveFname.getText()==null) ||
(saveLname.getText()==null)||
(savePassword.getText()==null)||
(saveRetype.getText()==null))
{
Toast toast = Toast.makeText(this, "All Fields are Required", Toast.LENGTH_SHORT);
toast.show();
}
}
}
}
- It keeps saving data even if one field is empty or even all fields are empty 2.Always notify the user "New Record Save"
Where am i wrong?