I am trying to check if a record exists after selecting it using a query. I have one record in the table which is 'Administrator' 'abc123' and I am trying to use the following code below:
//Define our database variables that we will use to get our data. dbhelper = new DBHelper(this); SQLiteDatabase db = dbhelper.getReadableDatabase(); //Define our select query here, check if username and password exists. String selectQuery = "SELECT * FROM " + dbTables.userTABLE + " WHERE " + dbTables.username + " = " + "'" + input_name + "'" + " AND " + dbTables.userpassword + " = " + "'" + input_password + "'"; Cursor c = db.rawQuery(selectQuery, null); //If the raw query was successfull. if(c.moveToFirst()){ Integer userID = c.getInt(0); String userName = c.getString(1); String userPassword = c.getString(2); boolean exists = (c.getCount() > 0); if( exists ) { Log.d("Database", userID.toString()); Log.d("Database", userName.toString()); Log.d("Database", userPassword.toString()); } else { Log.d("Database NO", "NO"); } } c.close(); db.close(); This works when the record exists however when the record doesn't exist it doesn't print anything at all. I have tried entering a different username and password that doesn't exist in the database and it doesn't seem to print anything. What am I doing wrong?