The principle is as follows: server-side design Delta table, record data operation sequence ID, and adding and deleting information. Keep the information in the Delta table while the database table operation is in progress.
The Android client uploads the last saved ID at the time of the request. The server determines the last ID, returns all operations after this ID, and the client modifies the database based on additions and deletions.
/* Update Unit table */public Long Add (list<contentvalues> units) {Boolean flag = False;long res = 0; Sqlitedatabase db = Getwritabledatabase (); for (int i = 0; i < units.size (); i++) {contentvalues CV = units.get (i); if (c V.getasstring ("Isdept"). Equals ("0")) {cv.put ("search", Name2search (cv.getasstring ("name"));} LOG.D (cv.getasstring ("type"), (String) cv.get ("type")), if (Cv.getasstring ("type"). Equals ("3")) {//Remove res = Db.delete ( Table_unit, "id =?", new string[] {cv.getasstring ("id")}); LOG.D ("Del", "" + res);} else if (Cv.get ("type"). Equals ("2")) {//Update cv.remove ("type"); res = Db.update (table_unit, CV, "id =?", new string[] {cv.ge Tasstring ("id")}); LOG.D ("Update", "" + res); else {//New Cv.remove ("type"); res = Db.insert (table_unit, NULL, CV); LOG.D ("Insert", "" + res);}} Db.close (); flag = True;r
Android Incremental Update principle