I want to get query from SQLite Database in my APP that consist of name, surname, username and also password.
when I click login button, it made crash. here is my code ##
public String Login(String Username, String Password) {
String Q = "SELECT * FROM " + DBHelper.TBLname + " WHERE "
+ DBHelper.ColumnUser + " = " + Username
+ " AND " + DBHelper.ColumnPass + " = " + Password;
Cursor LoginQuery = MyDB.rawQuery(Q, null);
if (LoginQuery == null) {
LoginQuery.close();
String LoginResult = "Wrong User Name and Password";
return LoginResult;
}
LoginQuery.moveToFirst();
String LoginResult = LoginQuery.getString(3);
LoginQuery.close();
return LoginResult;
}
Answer
Try this without dbhelper:
SELECT * FROM YOUR TABLE WHERE Username=Your Username AND Password=Your Password
No comments:
Post a Comment