我正在注册一个 android 应用程序。最初,当密码和确认密码不一样时,会提示“密码和确认密码不匹配”,并且成功。但是,如果密码和确认密码与空白匹配,则应出现此语句,“不要将任何字段留空”,不幸的是它失败了。
请帮我检查是否有任何错误。
btn2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
String username, password, cpassword, fullname, nric, address, phone, email;
username = tf3.getText().toString();
password = tf4.getText().toString();
cpassword = tf5.getText().toString();
fullname = tf6.getText().toString();
nric = tf7.getText().toString();
address = tf8.getText().toString();
phone = tf9.getText().toString();
email = tf10.getText().toString();
if(password != cpassword)
{
tv1.setText("Password & Confirm Password does not match.");
}
else if(username.equals("") || password.equals("") || cpassword.equals("") || fullname.equals("") || nric.equals("") || address.equals("") || phone.equals("") || email.equals(""))
{
tv1.setText("Do not leave any field empty.");
}
else
{
try
{
db.beginTransaction();
db.execSQL("insert into Members values('"+username+"','"+password+"','"+fullname+"','"+nric+"','"+address+"','"+phone+"','"+email+"');");
db.setTransactionSuccessful();
db.endTransaction();
}
catch(Exception e)
{
}
tv1.setText("Register Complete.");
}
}
});