1. <legend id='I6nod'><style id='I6nod'><dir id='I6nod'><q id='I6nod'></q></dir></style></legend>

  2. <small id='I6nod'></small><noframes id='I6nod'>

        <bdo id='I6nod'></bdo><ul id='I6nod'></ul>

      <i id='I6nod'><tr id='I6nod'><dt id='I6nod'><q id='I6nod'><span id='I6nod'><b id='I6nod'><form id='I6nod'><ins id='I6nod'></ins><ul id='I6nod'></ul><sub id='I6nod'></sub></form><legend id='I6nod'></legend><bdo id='I6nod'><pre id='I6nod'><center id='I6nod'></center></pre></bdo></b><th id='I6nod'></th></span></q></dt></tr></i><div id='I6nod'><tfoot id='I6nod'></tfoot><dl id='I6nod'><fieldset id='I6nod'></fieldset></dl></div>
      <tfoot id='I6nod'></tfoot>
    1. 带有 UPDATE 的 execSQL() 不更新

      execSQL() with UPDATE doesn#39;t update(带有 UPDATE 的 execSQL() 不更新)
      <tfoot id='nEA0o'></tfoot>
        <legend id='nEA0o'><style id='nEA0o'><dir id='nEA0o'><q id='nEA0o'></q></dir></style></legend>

              <tbody id='nEA0o'></tbody>
              <bdo id='nEA0o'></bdo><ul id='nEA0o'></ul>

                <i id='nEA0o'><tr id='nEA0o'><dt id='nEA0o'><q id='nEA0o'><span id='nEA0o'><b id='nEA0o'><form id='nEA0o'><ins id='nEA0o'></ins><ul id='nEA0o'></ul><sub id='nEA0o'></sub></form><legend id='nEA0o'></legend><bdo id='nEA0o'><pre id='nEA0o'><center id='nEA0o'></center></pre></bdo></b><th id='nEA0o'></th></span></q></dt></tr></i><div id='nEA0o'><tfoot id='nEA0o'></tfoot><dl id='nEA0o'><fieldset id='nEA0o'></fieldset></dl></div>

                <small id='nEA0o'></small><noframes id='nEA0o'>

                本文介绍了带有 UPDATE 的 execSQL() 不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 rawQueryexecSQL 方法来操作我的数据库,而不是 .update.insert 等.我正在尝试使用以下代码执行更新:

                I am trying to use rawQuery and execSQL methods for manipulating my database, instead of the .update, .insert, etc. I am trying to perform an UPDATE with the following code:

                db.execSQL("UPDATE configuration " +
                                "SET number_fields = " + number_fields + ", "
                                + "frequency = " + frequency + ", "
                                + "ag = " + ag + ", "
                                + "number_alarms = " + number_alarms + ", "
                                + "failed_rapper = " + failed_rapper + ", "
                                + "max_mv = " + max_mv + ", "
                                + "max_nav = " + max_nav + " "
                                + "WHERE serial_id = " + Integer.toString(id) + ";");
                

                在此操作之后,有一个日志表明发生了更新并且它似乎可以工作,但是当我尝试在表上执行 select 语句时,它返回并显示以下错误:

                AFter this action there is a log that states an update has occurred and it seems to work, yet when I try to do a select statement on the table, it returns with the following error:

                06-10 10:01:47.564: W/System.err(3815): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
                

                现在,我在 Android 中使用 SQLite 数据库浏览器手动插入的不同数据上执行了相同的 SELECT,它工作正常.我还在 SQLite 浏览器中执行了相同的 UPADTE,它在那里工作.因此,我知道问题在于 UPDATE 命令在 Android 上运行时不起作用.

                Now I have performed that same SELECT on different data in Android that I manually inserted using SQLite Database Browser and it works fine. I have also performed that same UPADTE in the SQLite Browser and it has worked there. Therefore I know that the problem is that the UPDATE command is not working when running on Android.

                问题:为什么 UPDATE 命令在 execSQL() 方法中不起作用?

                Question: Why does the UPDATE command not work within the execSQL() method?

                推荐答案

                来自Android SQLiteDatabase 类文档:

                执行不是 SELECT 或任何其他 SQL 的单个 SQL 语句返回数据的语句.

                Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

                没有办法返回任何数据(比如受影响的人数行).相反,我们鼓励您使用 insert(String, String,内容值),更新(字符串,内容值,字符串,字符串 [])等al,如果可能的话.

                It has no means to return any data (such as the number of affected rows). Instead, you're encouraged to use insert(String, String, ContentValues), update(String, ContentValues, String, String[]), et al, when possible.

                然后:

                对于 UPDATE 语句,请改用以下任何一种.

                For UPDATE statements, use any of the following instead.

                更新(字符串,内容值,字符串,字符串[])

                update(String, ContentValues, String, String[])

                updateWithOnConflict(String, ContentValues, String, String[], int)

                updateWithOnConflict(String, ContentValues, String, String[], int)

                据我所知,execSQL 方法更多用于更高级别的数据库操作,例如创建表和更改架构,以及 .query.update、.delete等方法来修改行.除了 .update 来执行这个操作.

                As far as I can tell, the execSQL method is more for higher level database operations, such as creating tables and changing schema, and the .query, .update, .delete, etc. methods should be used to modify rows. I'm not sure you have another option besides .update to perform this operation.

                这篇关于带有 UPDATE 的 execSQL() 不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Cannot solve SonarQube error quot;Make this line start at column 3quot;(无法解决 SonarQube 错误“使此行从第 3 列开始)
                SonarQube for multi module project for Android(适用于 Android 的多模块项目的 SonarQube)
                How to integrate sonarqube in android studio?(如何在 android studio 中集成 sonarqube?)
                Android What is the easist way Upgrade Database for existing DB(Android 为现有数据库升级数据库的简单方法是什么)
                Updating SQLite database android(更新 SQLite 数据库 android)
                Android: onUpgrade not calling at database upgrade(Android:onUpgrade 不在数据库升级时调用)
                    1. <small id='n6gt1'></small><noframes id='n6gt1'>

                      <i id='n6gt1'><tr id='n6gt1'><dt id='n6gt1'><q id='n6gt1'><span id='n6gt1'><b id='n6gt1'><form id='n6gt1'><ins id='n6gt1'></ins><ul id='n6gt1'></ul><sub id='n6gt1'></sub></form><legend id='n6gt1'></legend><bdo id='n6gt1'><pre id='n6gt1'><center id='n6gt1'></center></pre></bdo></b><th id='n6gt1'></th></span></q></dt></tr></i><div id='n6gt1'><tfoot id='n6gt1'></tfoot><dl id='n6gt1'><fieldset id='n6gt1'></fieldset></dl></div>
                        <bdo id='n6gt1'></bdo><ul id='n6gt1'></ul>
                      • <legend id='n6gt1'><style id='n6gt1'><dir id='n6gt1'><q id='n6gt1'></q></dir></style></legend>
                          <tbody id='n6gt1'></tbody>

                        <tfoot id='n6gt1'></tfoot>