Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中更新SQLite表的问题_Android_Sqlite - Fatal编程技术网

android中更新SQLite表的问题

android中更新SQLite表的问题,android,sqlite,Android,Sqlite,我想交换SQLite Android中特定列的两行的值 public void updatePosition(int oldVal, int newVal){ ContentValues updatedValue1 = new ContentValues(); updatedValue1.putNull(ColName); db.update(TABLE_NAME, updatedValue1, ColName + "==" + newVal, null); Co

我想交换SQLite Android中特定列的两行的值

public void updatePosition(int oldVal, int newVal){
    ContentValues updatedValue1 = new ContentValues();
    updatedValue1.putNull(ColName);
    db.update(TABLE_NAME, updatedValue1, ColName + "==" + newVal, null);
    ContentValues updatedValue2 = new ContentValues();
    updatedValue2.put(ColName, newVal);
    db.update(TABLE_NAME, updatedValue2, ColName + "==" + oldVal, null);
    ContentValues updatedValue3 = new ContentValues();
    updatedValue3.put(colName, oldVal);
    db.update(TABLE_NAME, updatedValue2, colName + " IS NULL", null);
}
如果我们假设oldVal=10和newVal=20,那么它应该是这样的

1st update : put null where value is 20 -- Now colName has 10 and null
2nd update : put 20 where value is 10   -- Now colName has 20 and null
3rd update : put 10 where value is null -- now colName has 20 and 10
所以最后的答案应该是20和10,但它显示了20和20

如果我的逻辑不正确,请帮助我


谢谢

上次更新时犯了多么愚蠢的错误。而不是这个

updatedValue3.put(colName, oldVal);
db.update(TABLE_NAME, updatedValue2, colName + " IS NULL", null);
我应该写这个

updatedValue3.put(colName, oldVal);
db.update(TABLE_NAME, updatedValue3, colName + " IS NULL", null);

谢天谢地……

我用=,替换了它,但结果还是一样的