Hello me again ( sorry )
I'm tiring to populate spinner from sqlitle and it is working fine BUT my table looks like:
_id | Name | Time | ....
_id: is self incremental number always unique Name: is name of person, repeats on many lines in this table
I want to put in spinner all names from this row but uniq no duplicates. how I'm doing it now:
private void updateSpiner(){ Spinner nameSpinner = (Spinner) findViewById(R.id.spinMena);
Cursor nameCursor = db.getNames();
startManagingCursor(nameCursor);
String[] from = new String[]{"Name"};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter nameAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, nameCursor, from, to);
nameSpinner.setAdapter(nameAdapter);
}
here is how I get the data:
public Cursor getNames(){
final String KEY_TITLE = "Name";
final String KEY_ROWID = "_id";
return database.query("plan", new String[] {KEY_ROWID, KEY_TITLE}, null, null, null, null, null);
}
can somebody explain to me why I need to get also _id row for this, I'm still now to Java and I don't see why I need it, except if I don't do it it will complain that there is no _id.
Buts it is not used in first method I get only Names from it... because of _id I can't use in query DISTINCT = true because it still return all rows as _id is unique for each line..
Could someone help me to wrap my head around it ? I don't want to make separate table or something..
Thanks, Vlad