Resetting Autoincrement in Android SQLite

前端 未结 4 1770
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 10:53

I have this method which will remove all rows from a table but I also want it to reset the autoincrement so that when a new row is added it will start again. The SQL stateme

4条回答
  •  青春惊慌失措
    2020-12-31 11:36

    I was trying too hard.

    Finally, I got this answer code...

    Book.deleteAll(Book.class);
    book=new Book(user, pass);
    book.setId(Long.valueOf(book.listAll(Book.class).size()));
    book.save();
    

    this code work like delete and recreating the table.and reset id.

    good luck

提交回复
热议问题