I delete the data from the table. After that, I start filling it up again. But the key (_id) does not write as the first value. And the account continues on. How to reset it?

//Добавление данных public long setInsert(String table, String nullColumnHack, ContentValues values) { return myDataBase.insert("NicknamePersony", nullColumnHack, values); } //Удаление данных public void delete(String table) { myDataBase.delete("NicknamePersony", null, null); } 

    2 answers 2

    To reset the AUTOINCREMENT , after deleting all the records in the table, execute the following query: db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME + "'"); where TABLE_NAME is the name of your table.

    Source: https://stackoverflow.com/q/9759502/2506123

    Update: But, and if you do not want to delete all the entries, then read what is written in the answer @pavlofff.

    • Thank you, it works)) - Vitaly Robinovsky

    No, this is not required. ID is not a position counter, but a unique identifier. In one table there cannot be two identical IDs, no matter whether the records were deleted or not, one of the main concepts of the relational database would be broken.

    • Thank you)) figured out - Vitaly Robinovsky