删除行后可以刷新SQLite数据索引(_id)吗?

时间:2016-12-09 02:45:20

标签: android sqlite

我创建了一个表并插入了5行

  public void run() {
    long lastTime = System.nanoTime();
    long secondsTimer = System.currentTimeMillis();
    long nowTime;
    double ns = 1000000000 / 60;
    double delta = 0;
    int updates = 0;
    int fps = 0;
    while (!quit) {
      nowTime = System.nanoTime();
      delta += (nowTime - lastTime) / ns;
      lastTime = nowTime;
      while (delta >= 1) {
        --delta;
        update();
        ++updates;
      }
      repaint();
      ++fps;
      if (System.currentTimeMillis() - secondsTimer >= 1000) {
        secondsTimer += 1000;
        window.setTitle(GAME_TITLE + " | UPDATES: " + updates + " FPS: " + fps);
        updates = 0;
        fps = 0;
      }
    }
  }

当我删除_id = 4时,数据库变为

1  testsql 3456 
2  tese weqe 
3  testdfs sfd 
4  testsfssql 3sf6 
5  tese weqe 

我可以将SQLite数据索引(_id)刷新到

1  testsql 3456 
2  tese weqe 
3  testdfs sfd 
5  tese weqe 

1 个答案:

答案 0 :(得分:0)

完全没用,但你可以这样做(使用你删除_id = 4的例子)

UPDATE table SET _id = _id - 1 WHERE _id > 4;