i'm working sqlite.i successfully create database and table.and also i can register some new user.and also i wrote login function with username only this is a part my code
public String getSinlgeEntry(String username) {
Cursor cursor = db.query(usm_Users, null, " UserName=?",
new String[] { username }, null, null, null);
if (cursor.getCount() < 1) // UserName Not Exist
{
cursor.close();
return "NOT EXIST";
}
cursor.moveToFirst();
String customername = cursor.getString(cursor
.getColumnIndex("UserName"));
cursor.close();
return customername;
}
String username=namefild.getText().toString();
String password=passwordfild.getText().toString();
String storedusername=loginDataBaseAdapter.getSinlgeEntry(username);
if(username.equals(storedusername))
{
Toast.makeText(MainActivity.this, "Congrats: Login Successfully", Toast.LENGTH_LONG).show();
Intent ii=new Intent(MainActivity.this,Home.class);
startActivity(ii);
}
else
if(username.equals("")){
Toast.makeText(MainActivity.this, "Please Enter Your Password", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(MainActivity.this, "Password Incorrect", Toast.LENGTH_LONG).show();
}
}
i can check login only username.how i can write two parameters function witch would can check username and password together?
public String getSinlgeEntry(String username,String password) {
Cursor cursor = db.query(usm_Users, null, " UserName=?",
new String[] { username }, null, null, null);
if (cursor.getCount() < 1) // UserName Not Exist
{
cursor.close();
return "NOT EXIST";
}
cursor.moveToFirst();
String customername = cursor.getString(cursor
.getColumnIndex("UserName"));
cursor.close();
return customername;
}
i must change something my Cursor .if anyone knows solution please help me
use double ? and send two parameter in array.
like: