:)
I have a table Customer with 3 fields (id, name, email) and I'd like to get only the name of all customers and show it on a Spinner. Any idea on how I could do it?
How I get all data
public Cursor getAllData ()
{
String buildSQL = "SELECT * FROM " + DatabaseHelper.Customers.TABLE;
return database.rawQuery(buildSQL, null);
}
DatabaseHelper file, with the table and column
public static class Customers
{
public static final String TABLE = "customers";
public static final String _ID = "_id";
public static final String NAME = "name";
public static final String EMAIL = "email";
public static final String[] COLUMNS = new String[]
{
_ID, NAME, EMAIL
};
}
I thought about using
String buildSQL = "SELECT * FROM " + DatabaseHelper.Customers.COLUMNS;
But i am not sure how I could retrieve the name only. Any tips? Thanks on advance, guys!
Aucun commentaire:
Enregistrer un commentaire