Q:

How exactly SQLite database update primary key id?

Suppose I have a table contacts
  id        Name            Contact_No
-----------------------------------------
   1        abc                12345
   2        lmn                56784
   3        pqr                83654
   4        uvw                17637
   5        xyz                98345

If I delete row 3 from database, what would be the id of rows following the deleted row?
And if I update row 4, will it be given a new id or the id of row 4 will remain same after updating database?
What is the difference between autoincrement and autoincrement not null? Official documentation says that it will degrade the performance and database will work slow. Is it mandatory to write it along with integer primary key?
I have read many stackoverflow answers and also read SQLite Official Documentation but I couldn't get it.

A:

Assuming id is the name of your INTEGER PRIMARY KEY column.
If you update a row, it will never change its id, since it is still the same row. (that's the whole point of update).
Regarding the creation of new ids, everything is in the doc your linked:
Relevant sections :
Without AUTOINCREMENT

On an INSERT, if the ROWID or INTEGER PRIMARY KEY column is not explicitly given a value, then it will be filled automatically with an unused integer, usually the one more than the largest ROWID currently in use.

There is no strict rule, it can be implementation dependent. Usually it will be equal to select max(id)+1. In you case 6, but if you delete row 5, the id 5 can be reused. (But don't rely on this).
With AUTOINCREMENT

If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT (...) the ROWID chosen for the new row is at least one larger than the largest ROWID that has ever before existed in that same table. If the table has never before contained any data, then a ROWID of 1 is used.

Adding NOT NULL to AUTOINCREMENT is therefore pointless.
In your case, the next id is 6, no matter how many rows you delete before that.

