jeudi 22 janvier 2015

near "@gmail" Syntax error

i am creating login activity with Boolean function but get error while match email address with email address in database but give error



this is my dbHandler class method




public Boolean loginCheck(String email,String password)
{
Boolean flag=false;
String selectQuery = "SELECT * FROM " + TABLE_NAME + " WHERE email=" + email +" AND pass="+password;

SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() == 1){
flag=true;
}
else
{
flag=false;
}

return flag;
}


this is java file code



login.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String emailValue=edtEmail.getText().toString();//this is EditText
String passValue=edtPass.getText().toString();

if(db.loginCheck(emailValue, passValue))
{
Intent in = new Intent(getApplicationContext(), Home.class);
startActivity(in);
Toast.makeText(getApplicationContext(), "Login Successful", 2000).show();
}
else
{
Toast.makeText(getApplicationContext(), "Username and Password not match", 5000).show();
}
}
});


get error



01-23 04:58:30.519: E/AndroidRuntime(2422): android.database.sqlite.SQLiteException: near "@gmail": syntax error (code 1): , while compiling: SELECT * FROM login WHERE email=stackoverflow@gmail.com AND pass=stackoverflow
01-23 04:58:30.519: E/AndroidRuntime(2422): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
01-23 04:58:30.519: E/AndroidRuntime(2422): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)


please provide Solution of it


1 commentaire: