0

I am deleting all the contents in my database with the following code

 db.delete("teacher_info", null, null);

but adding data to the same table results in the id field to increment the row id from the previous counter. How can i set the if field to start counting from 1 after deleting the elements

Sagar Acharya
  • 1,435
  • 2
  • 16
  • 34
  • 1
    It would actually count starting from 0. Anyway, you shouldn't be so concerned about the ids. Let SQLite create whichever it wants to. – Phantômaxx Jun 14 '17 at 16:03
  • i am actually creating a dynamic database so that i will need to receive data dynamically. for that i need the values to be lined in a sequential format so that i can call them squentially from a for loop – Sagar Acharya Jun 14 '17 at 16:04
  • 1
    You can use a while loop (mind that ids don't necessarily match array indexes or whichever container you put them into) – Phantômaxx Jun 14 '17 at 16:06

1 Answers1

1

Try this command after

db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME + "'");
Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
VinayagaSundar
  • 1,553
  • 15
  • 17