How to update KEY_ROWID after deleting a row in SQLite database

前端 未结 2 1964
离开以前
离开以前 2021-01-21 14:19

How can I update the KEY_ROWID number in SQLite database after deleting a row from the database? CASE 1: For example, if I have five rows in the database, maximum KEY_ROWID is

2条回答
  •  广开言路
    2021-01-21 15:09

    The solution is that rewriting the table with a new array or list ;

    reWriteTable is will allow automatic sorting of rows.

    private void reWriteTable(){
        if(db.listOfDate().size()!=0){
            String[] name =new String[db.listOfDate().size()] ;
            String[] note=new String[db.listOfDate().size()] ;
            String[] date =new String[db.listOfDate().size()];
            String[] time =new String[db.listOfDate().size()];
            String[] total =new String[db.listOfDate().size()];
    
            for(int i=0;i

    Define deleting table in Database.java ;

     protected void deleteTable(){
            SQLiteDatabase db=this.getWritableDatabase();
            db.execSQL(" drop table if exists " + TABLO_UYGULAMALAR + ";");
            onCreate(db);
    
        }
    

提交回复
热议问题