我的应用程序中有一个数据库,当我使用数据库行ID执行删除操作时,行项将被删除,但我的表保留该空行。我该如何删除?
数据库类:
public class ContactDatabase extends SQLiteOpenHelper {
SQLiteDatabase db;
public static final String DATABASE_NAME="totalContact1.db";
public static final String TABLE_NAME="mecontact1";
public static final String NAME="name";
public static final String PHONE="phone";
public static final String UID="_id";
public ContactDatabase(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL("create table mecontact1" +
"(_id integer primary key autoincrement, name text, phone text)");
}catch(android.database.SQLException e){
System.out.println("table create nhi ho rha");
}
}
public void deleteContact(String d,int pos){
db=this.getWritableDatabase();
db.delete(TABLE_NAME, UID + "= ? ", new String[] {String.valueOf(pos)});
}
}
当我在db.delete(TABLE_NAME, UID + "= ? ", new String[] {String.valueOf(pos)});
中执行deleteContact(String d,int pos)
操作时,该表会保留空行的记录。如何使用_id列顺序重新排列表格?