【问题标题】:Android Api 28 - crash_report=Exception is: android.database.sqlite.SQLiteExceptionAndroid Api 28 - crash_report=异常是:android.database.sqlite.SQLiteException
【发布时间】:2023-01-21 01:58:46
【问题描述】:

我编写了以下查询,该查询在 Api 29 和 30 上运行良好,但应用程序仅在 Api 28 上崩溃,日志如下 System.out: crash_report=Exception is: android.database.sqlite.SQLiteException: no such column: true (代码 1 SQLITE_ERROR): , 编译时: update doctor set is_rogspFiled = true where doctor_contactid = 784829 这是我的查询。我需要改变什么?

 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();

【问题讨论】:

    标签: android android-sqlite android-database android-api-levels sqliteexception


    【解决方案1】:

    也许问题出在您的清单中您具有读写权限?

    看数据库是不是这个版本创建的。

    GL

    【讨论】:

      【解决方案2】:

      API 28中使用的SQLite版本是3.22.0(查看this thread),但是version 3.23.0中的SQLite中引入了常量truefalse分别作为10的别名。

      在您的声明中,您必须将返回truefalseisFiled更改为整数10

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

      但是,将参数连接到 SQL 语句总是一个坏主意。
      您应该使用 update() 方法,其中使用 ? 占位符来传递参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-05
        • 1970-01-01
        • 1970-01-01
        • 2019-07-30
        • 1970-01-01
        • 1970-01-01
        • 2013-10-04
        • 2019-07-08
        相关资源
        最近更新 更多