简体   繁体   English

Android Api 28 - crash_report=异常是:android.database.sqlite.SQLiteException

[英]Android Api 28 - crash_report=Exception is: android.database.sqlite.SQLiteException

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.我写了下面的查询,它在 Api 29 和 30 上运行良好,但应用程序在 Api 28 上崩溃,只有以下日志 System.out: crash_report=Exception is: android.database.sqlite.SQLiteException: no such column: true ( code 1 SQLITE_ERROR): ,编译时:update doctor set is_rogspFiled = true where doctor_contactid = 784829 这是我的查询。 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();

Maybe the problem be in your manifest you have read and write permissions?也许问题出在您的清单中您具有读写权限?

See if the database is created in this version.看数据库是不是这个版本创建的。

GL GL

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 . API 28 中使用的 SQLite 的版本是 3.22.0(检查此线程),但是常量truefalse在 SQLite 的版本 3.23.0中分别作为10的别名引入。

In your statement you must change isFiled which returns true or false to an integer 1 or 0 :在您的声明中,您必须将返回truefalse的 isFiled 更改为isFiled 10

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.但是,将参数连接到 SQL 语句总是一个坏主意。
You should use the method update() where you use ?你应该在你使用的地方使用方法update() ? placeholders to pass the parameters.传递参数的占位符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM