I have problems extracting data from an Android SQLite database. The only solution is to lower the SDK, but I am getting errors when thinking of the SDK. Does anyone have a solution for this issue?
I have problems extracting data from an Android SQLite database. The only solution is to lower the SDK, but I am getting errors when thinking of the SDK. Does anyone have a solution for this issue?
Simple Fix
Right click on the error, click on Show Context Actions and chose the ADD @SuppressLint("Range") annotation and the error message will be supressed.
In short as -1 can be returned, (column not found), then for some reason this is detected as an error.
As you have experienced it didn't use to be considered an error.
Alternative Fix
An alternative is to use the getColumnIndex prior to using it within a Cursor get??? method.
e.g. something like
int kisi_add_idx = c.getColumnIndex(kisi_add);
....
String kisi_add = c.getString(kisi_add_idx);
If the column isn't found, without testing for the -1, then you will still get an index out of bounds error. Note that getColumnIndex is (incorrectly) case sensitive (as you are using variables for the column names this would probably not be an issue).