Im making a login and register system and if need to check if the user already exits so I wrote this function in my database handler to check it.
public boolean checkIfUserExits(String username){
SQLiteDatabase db = this.getWritableDatabase();
String query = "SELECT * FROM " + TABLE_NAME + " WHERE username=" + "\"" + username + "\"";
Cursor cursor = db.rawQuery(query, null);
if(cursor.getCount() <= 0){
cursor.close();
return false;
}
cursor.close();
return true;
}
But the problem if that i always getting a true. Thanks for help.
Aucun commentaire:
Enregistrer un commentaire