1

I have written the below query which is working fine on Api 29 and 30 but app is crashing on Api 28 only with the following log System.out: crash_report=Exception is: android.database.sqlite.SQLiteException: no such column: true (code 1 SQLITE_ERROR): , while compiling: update doctor set is_rogspFiled = true where doctor_contactid = 784829 Here is my query. What do I need to change?

 query = " update " + TABLE_DOCTOR + " set " + Queryclass.DOCTOR_ROGSP_STATUS + " = " + isFiled + " where " + Queryclass.DOCTOR_CONTACTID + " = " + gspid ;
    cursor = sd.getData(query);

    if (cursor.moveToNext()) {
        isFiled = true;
        ContentValues contentValues = new ContentValues();
        contentValues.put(Queryclass.DOCTOR_ROGSP_STATUS, isFiled);
        sd.update(Queryclass.TABLE_DOCTOR, contentValues, query);
    }

    cursor.close();
    sd.close();

2 Answers 2

2

The version of SQLite used in API 28 is 3.22.0 (check this thread), but the constants true and false were introduced as aliases of 1 and 0 respectively in SQLite in version 3.23.0.

In your statement you must change isFiled which returns true or false to an integer 1 or 0:

query = "update " + TABLE_DOCTOR + " set " +
        Queryclass.DOCTOR_ROGSP_STATUS + " = " + (isFiled ? 1 : 0) + 
        " where " + Queryclass.DOCTOR_CONTACTID + " = " + gspid;

But, concatenating parameters to SQL statement is always a bad idea.
You should use the method update() where you use ? placeholders to pass the parameters.

Sign up to request clarification or add additional context in comments.

Comments

0

Maybe the problem be in your manifest you have read and write permissions?

See if the database is created in this version.

GL

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.