0
我正在登录页面。在以下代码中,userEntered
和pswdEntered
是EditText
收集用户输入。我在我的数据库中通过userEntered
作为方法getSingleEntry
中的参数。我想用这种方法检查数据库中的用户名并返回相应的密码。方法getSingleEntry
将如何查看?Android登录错误
boolean diditwork = true;
try {
String userEntered= user.getText().toString();
String pswdEntered = pswd.getText().toString();
String storedPassword=LoginDB.getSingleEntry(userEntered);
Log.d("blahhhhhhhhh", storedPassword);
if(pswdEntered.equals(storedPassword))
{
Dialog id=new Dialog(Login.this);
id.setTitle("LOGIN");
TextView tyv=new TextView(Login.this);
tyv.setText("Registration Successful!");
id.setContentView(tyv);
}
else
{
Dialog id=new Dialog(Login.this);
id.setTitle("LOGIN");
TextView tyv=new TextView(Login.this);
tyv.setText("Incorrect username or password!");
id.setContentView(tyv);
id.show();
}
} /* catch(SQLException ee)
{
diditwork=false;
String error=ee.toString();
Dialog id=new Dialog(Login.this);
id.setTitle("SQLSQLSQLSQL");
TextView tyv=new TextView(Login.this);
tyv.setText(error);
id.setContentView(tyv);
id.show();
}*/
catch(Exception e)
{
diditwork=false;
String error=e.toString();
Dialog id=new Dialog(Login.this);
id.setTitle("LOGIN");
TextView tyv=new TextView(Login.this);
tyv.setText("Retype password"+error);
id.setContentView(tyv);
id.show();
}
这些是数据库定义。
public static final String KEY_ROWID="_id";
public static final String KEY_NAME= "name";
public static final String KEY_USERNAME="username";
public static final String KEY_PASSWORD="password";
public static final String KEY_MOBILE= "mobile";
public static final String KEY_EMAIL= "email";
private static final String DATABASE_NAME="LoginDB";
private static final String DATABASE_TABLE="DoctorTable";
private static final int DATABASE_VERSION=2;
发表您的'getSingleEntry()' –