Android spinner/sqlite database - getting cursor position not contents!
So my setup is that I have a database with two tables. My main input class is a basic form which has a spinner to select a category. Category is the second table, the spinner is powered by this database table and the main table has a foreign key of this table.
I have the spinner populating correctly etc but when storing the selected item from the spinner it is storing the cursor position which looks like:
android.database.sqlite.SQLiteCursor@43开发者_开发百科5b9ba0.
rather than the actual contents of it which should be the name from the database. The code I am using is:
String fkstring = mSpinner.getSelectedItem().toString();
If anyone could let me know how to solve this that would be great.
use .getString(0)
to get a string, .getString(0)
will get the first column .getString(1)
the second etc etc.
String fkstring = mSpinner.getSelectedItem().getString(0);
Try String fkstring = (String) mSpinner.getSelectedItem();
精彩评论