Hello, I need help to load a spinner from a database as easily as possible.
I have a class where doing all sorts of methods would ideally be that from the activity call those methods and load the spinner.
public ArrayList getAllClientes() {
ArrayList list = new ArrayList<>();
//String[] campos = new String[]{NOMBRE_CLIENTE, DIRECCION_CLIENTE};
Cursor c = db.rawQuery("SELECT * FROM "+TABLA_CLIENTE, null);
try {
while (c.moveToNext()){
Cliente cli = new Cliente();
cli.setId(c.getInt(0));
cli.setNombre(c.getString(1));
cli.setDireccion(c.getString(2));
list.add(cli);
}
} finally {
c.close();
}
return list;
}
public Cursor getAllClientes(){
return db.rawQuery("SELECT * FROM "+TABLA_CLIENTE, null);
}
Those are the methods I was trying to bring the data from the bd but I do not know if they serve me and that's how I do not know how to set the spinner