i basically want to use the query select password from Login_table where username ='this will be given by the user';
Cursor res =db.rawQuery("select password from Login_table where username ='"+x+"'",null);
i guess this is right but still getting a problem
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
public void checkData(){
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String user_name=usname.getText().toString();
Cursor res =mydb.getData(user_name);
if(res.getCount()==0){
Toast.makeText(MainActivity.this,"Login failed",Toast.LENGTH_SHORT);
}
String check=res.getString(2);
Toast.makeText(MainActivity.this,String.valueOf(check),Toast.LENGTH_SHORT).show();
String pass_Word=pass.getText().toString();
if(pass_Word.compareTo(check)==0){
Toast.makeText(MainActivity.this,"You are Loged IN",Toast.LENGTH_LONG).show();
}
else
Toast.makeTextenter code here(MainActivity.this,"You are Not Loged IN",Toast.LENGTH_SHORT).show();
}
});
}
i just want to retrieve the password and check with the users inputenter code here