I've looked at similar questions but they don't explain how to use a CursorAdapter.
What I'm trying to do is populate a Spinner with a column of Strings read from a selected database.
This is my current code:
//open database depending on selected item
myDatabase = openOrCreateDatabase("Courses"+spSem.getSelectedItem().toString(),MODE_PRIVATE,null);
//read fields to be populated and store them in an arraylist, I need to use arraylist since not every database has the same size
Cursor resultSet = myDatabase.rawQuery("Select * from Subject",null);
resultSet.moveToFirst();
List<String> course = new ArrayList<String>();
for (int i = 1; i < course.size(); i++) {
course.add(resultSet.getString(i));
}
This next part is where I'm stuck, I'm thinking I need to use CursorAdapter() to populate the spinner, but I have no idea how? Previously I had this:
String[] cArr = new String[course.size()];
course.toArray(cArr);
CursorAdapter a = new CursorAdapter(this,cArr,android.R.layout.simple_spinner_item);
a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spCourse.setAdapter(a);
With this code I get the error "CursorAdapter is abstract and cannot be instantiated", and "cannot resolve method'setDropDownView'".