db.open();
cursor = db.getAllRecords();
int i = 0;
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()) {
spinnerItems[i] = cursor.getString(NAME_COLUMN);
Log.v(TAG, "spinnerItem "+i+"="+spinnerItems[i]);
i++;
}
Why does the code above give this result in LogCat?:
spinnerItem 0=name1
spinnerItem 1=name2
spinnerItem 2=name3
spinnerItem 3=name4 and so on
When the database looks like this:
row name
0 name0
1 name1
2 name2
3 name3
4 name4 and so on.
And what is the best way to populate a spinner with the entire content from one column of a database? Above I (try to) create spinnerItems[] whish I then arrayAadapters into the spinner.