public ArrayList<Contato> filtrar(String filtro) {
ArrayList<Contato> contatoArray = new ArrayList<>();
//Consulta que traz todos dados de todas colunas
Cursor cursor = database.query(BaseDAO.TABELA_AGENDA, BaseDAO.COLUNAS_TABELA_AGENDA, null, null, null, null, BaseDAO.CONTATO_NOME);
cursor.moveToFirst();
while(!cursor.isAfterLast()) {
Contato c = new Contato();
if (cursor.getString(1).equalsIgnoreCase(filtro) || cursor.getString(3).equalsIgnoreCase(filtro)) {
c.setId(cursor.getInt(0));
c.setNome(cursor.getString(1));
c.setTelefone(cursor.getString(2));
c.setEmpresa(cursor.getString(3));
c.setBrunko(cursor.getInt(4) == 1);
c.setCarter(cursor.getInt(5) == 1);
c.setFortmetal(cursor.getInt(6) == 1);
c.setNdflex(cursor.getInt(7) == 1);
c.setNotus(cursor.getInt(8) == 1);
c.setMerco(cursor.getInt(9) == 1);
c.setMetan(cursor.getInt(10) == 1);
c.setRiosulense(cursor.getInt(11) == 1);
c.setYming(cursor.getInt(12) == 1);
c.setMesContato(cursor.getInt(13));
c.setAnoContato(cursor.getString(14));
contatoArray.add(c);
}
cursor.moveToNext();
}
cursor.close();
return contatoArray;
}
My code seems to be correct with Log.d()
I got the values of filtro
, cursor.getString(1)
and cursor.getString(3)
which are the same, for example "Test Name", "Test Name" and "Test Company" but they do not enter if()
what is wrong?