문제

I have to reset the autoincrement in my database. I can't do the "drop table" and recreate the table.

is there anyway to reset the autoincrement?

도움이 되었습니까?

해결책

It is possible using this Query

db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + name_of_the_table + "'");

다른 팁

I use this one, maybe it will help

    public boolean deleteAll() {

    SQLiteDatabase db = this.getReadableDatabase();
    db.delete("SQLITE_SEQUENCE","NAME=?",new String[]{TABLE_NAME});
    int affectedRows = db.delete(this.TABLE_NAME, null, null);
    return affectedRows > 1;
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top