Q:

Deleting row from android SQLite database corrupts entries after deleted row

Hi everyone I am fairly new to android development and have been trying to learn how to use SQL with android. I have been working with the example code from here http://www.tutorialspoint.com/android/android_sqlite_database.htm
I have been able to get everything working like I want it except for the delete row function. When I delete a row the data in the rows below it become corrupt and/or out  of sync with the id column. I have been looking at examples and goggling it for the last two days but just can not find a answer so I hope one of you can help. Below is a simple example of what is happening. Let me know if I need to post any more info, any help is greatly appreciated.Diagram of problem
public Integer deleteContact (Integer id)
{
   SQLiteDatabase db = this.getWritableDatabase();
  return db.delete("contacts",
           "id = ? ",
          new String[] { Integer.toString(id) });

}

A:

The results of the diagram are correct. Also the code is correct.
If you have got:
ID | Value
----------
1  | a
2  | b   <---- delete this
3  | c

the result will be:
ID | Value
----------
1  | a
3  | c

So the row with the id 3 has still the value c.
And if you run a query which selects the row with ID 2, the app might crash, because the returned Cursor does not point to a row.
If such a case is not handled, the app might crash.

