Skip to content
Advertisement

Cursor running into error while attempting to read data from SQLite database (Android Studio)

I have been trying to debug this for hours now and I am at a complete dead end. I am creating a program where you enter the current date and your current weight into a screen in Android Studio then click submit. That date gets sent to an SQLite database with two columns for data – “date” and “weight”. There are so many classes and things going on that this is nearly impossible to debug.

I have tried changing variables names, upgrading from SQLite database version 1 to version 2, making sure my sets and gets are working properly… I don’t know what is going on. The errors I get include these main 3… so when I enter date and weight and click submit, i get this logcat error:

JavaScript

I would a million times appreciate any help. I’m going back and forth trying to figure this out and am so so lost. Also here is my database handler class:

JavaScript

and ReadData for sets and gets (which is one of the errors) I believe the setter for date might not be working because it is gray while the set for the weight is not gray in the code:

JavaScript

Advertisement

Answer

You forgot to add id column

values.put(ID_COL, null);

//By doing an insertion without specifying list of columns, you need a number of values exactly matching the number of columns and must use NULL as a placeholder

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