I am making an android app where there is a basic login function. I already created the accounts. It logins successfully but I am bothered by an error (don't know why it's an error if it works fine). This shows red:
E/DatabaseHelper(20507): SELECT * FROM users WHERE u_name = 'admin' AND u_password = '21232f297a57a5a743894a0e4a801fc3'
Here's the code from the DatabaseHelper
public UserModel getUser(String user_name, String user_password) {
SQLiteDatabase db = this.getReadableDatabase();
String selectQuery = "SELECT * FROM " + TABLE_USER + " WHERE "
+ KEY_USERNAME + " = '" + user_name + "' AND " + KEY_PASSWORD + " = '" + user_password + "'";
Log.e(LOG, selectQuery);
Cursor c = db.rawQuery(selectQuery, null);
if (c != null)
c.moveToFirst();
UserModel ur = new UserModel();
ur.setId(c.getInt(c.getColumnIndex(KEY_ID)));
ur.setUname((c.getString(c.getColumnIndex(KEY_USERNAME))));
ur.setPassword(c.getString(c.getColumnIndex(KEY_PASSWORD)));
ur.setPrivilege(c.getString(c.getColumnIndex(KEY_PRIVILEGE)));
return ur;
}
And here's the call:
UserModel user = new UserModel();
user = db.getUser(username, pw);
Aucun commentaire:
Enregistrer un commentaire