我试图通过电子邮件地址获取用户名和密码并将其作为电子邮件发送[密码恢复].....我可以通过电子邮件检查用户的存在,但现在我需要通过他/她之前提供的电子邮件......
这是我的 DB_Class
public boolean getEmail(String emailNo) throws SQLException //pass the EmailNo which you want in where clause
{
Cursor mCursor = db.rawQuery("SELECT Username, Passwords FROM " + USERS_TABLE + " WHERE EmailNO='"+emailNo+"'",null);
if (mCursor != null) {
if(mCursor.getCount() > 0)
return true;
}
return false;
}
还有我的用于检查用户存在和发送电子邮件的 Activity 类。下面是
public void onClick(View v) {
String EmailAddress = txtEmailAddress.getText().toString();
try{
if(EmailAddress.length() > 0)
{
DBAdapter dbUser = new DBAdapter (RecoverPassword.this);
dbUser.open();
if(dbUser.getEmailAddress(EmailAddress))
{
Toast.makeText(RecoverPassword.this,"Email Successfully ", Toast.LENGTH_LONG).show();
String to = txtEmailAddress.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
email.putExtra(Intent.EXTRA_SUBJECT, "Password Recovery");
if(dbUser.getEmail(EmailAddress)){
email.putExtra(Intent.EXTRA_TEXT,dbUser.getEmailAddr(obj.getusername(),obj.getpassword())) ;
}else{
Toast.makeText(RecoverPassword.this,"Email Not matching " ,Toast.LENGTH_LONG).show();
}
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "gmail :"));
}else{
Toast.makeText(RecoverPassword.this,"Invalid Email", Toast.LENGTH_LONG).show();
txtEmailAddress.setTex