I am trying to get a string from a spinner which gets its information from a database. When using
spinner.getSelectedItem().toString();
I get strings like "android.database.sqlite.SQLiteCursor@412f3ff8". To get the resolved string, I tried to query the database using a cursor but it causes an IllegalStatException while a message in LogCat appears saying "Failed to read row 1, column 2 from a CursorWindow which has 3 rows, 2 columns.".
The numbers for the row and column are correct as the cell which should be found there contains the value I want to query.
Here's the code I used:
int selection = (int) spinner.getSelectedItemId(); //I get the selected item id.
Cursor selectioncursor = db.getAllSubjects(); //This is a query getting all the contents from the table
selectioncursor.moveToPosition(selection); //The id I got earlier equals the number of the row, the data is stored in, so I move the cursor to the correct row.
String subject = selectioncursor.getString(2); //Now the cursor should get the string from column 2 which is the one containing all the values (first column is "_id" of course)
Thank you, for your help.