Skip to content
Advertisement

Send spinner data to database

I am trying to send data to database from a spinner I initialize the database like this SPINNER + " TYPE ";

And in insert data method I put it as Type spinner but this line gives me an error contentValues.put(SPINNER, spinner);

what should I put there instead of put

JavaScript

Advertisement

Answer

You are trying to save a spinner object in the database which of course fails.
Change the data type of the column SPINNER to TEXT in the table:

JavaScript

Also change the data type of the argument spinner to String in the definition of insertData():

JavaScript

When you call insertData() pass the selected item of the spinner instead of the spinner itself:

JavaScript

Now uninstall the app from the device to delete the database and rerun so it is recreated with the proper data type for the column SPINNER.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement