Android Incremental Update principle

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.