I have a table called BUSINESS, with name, category, time, address.
Create a method:
public List<Negocio> findFilter(String selection){ //BUSCAR CON FILTRO
//Cursor cursor = database.query(NegociosDBOpenHelper.TABLE_NEGOCIOS,allcolumns,selection,null,null,null,orderBy);
Cursor curso = database.rawQuery("SELECT " +NegociosDBOpenHelper.COLUMN_CATEGORIA +
" FROM " + NegociosDBOpenHelper.TABLE_NEGOCIOS +
" WHERE " + NegociosDBOpenHelper.COLUMN_CATEGORIA +
" LIKE '% " + selection + "'" , null);
List<Negocio> negocio = cursorToList(curso);
return negocio;
}
Where I call it, and then place it in a ListView:
categoria = bundle.getString("categoria");
negocio = dataSource.findFilter(categoria);
lista = (ListView) findViewById(R.id.lista);
if (negocio.size()==4){ //5
createdata();
negocio = dataSource.findAll();
}
RefreshDisplay();
}
public void RefreshDisplay(){
ArrayAdapter<Negocio> adapter = new ArrayAdapter<Negocio>(this,android.R.layout.simple_selectable_list_item,negocio);
lista.setAdapter(adapter);
}
}
But it does not give me any results. The category variable works, as it performs a toast to check.