Example usage for android.database.sqlite SQLiteDatabase update

List of usage examples for android.database.sqlite SQLiteDatabase update

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase update.

Prototype

public int update(String table, ContentValues values, String whereClause, String[] whereArgs) 

Source Link

Document

Convenience method for updating rows in the database.

Usage

From source file:com.rener.sea.DBHelper.java

private long setSyncItem(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//from   w  w  w.j av a 2  s . co m
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_ITEM, values, DBSchema.ITEM_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.ITEM_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncOption(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/* w  w w .  j a v  a 2  s.c o m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_OPTION, values, DBSchema.OPTION_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.OPTION_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncPerson(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//from  w w  w.java 2s.  c o m
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_PERSON, values, DBSchema.PERSON_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.PERSON_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncAppointments(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/* w w w  .java 2  s  .  c o m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_APPOINTMENTS, values, DBSchema.APPOINTMENT_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.APPOINTMENT_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncAddress(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/* w ww .  j av a  2  s .c  o  m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_ADDRESS, values, DBSchema.ADDRESS_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.ADDRESS_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncCategory(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from www  . j  a va 2s .c  om*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_CATEGORY, values, DBSchema.CATEGORY_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.CATEGORY_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncLocation(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//from   w w  w  . ja v a  2 s  .c o  m
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_LOCATION, values, DBSchema.LOCATION_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.LOCATION_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncReport(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;//  www  .  j av a  2 s.  c om
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_REPORT, values, DBSchema.REPORT_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.REPORT_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncUsers(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from  w w w . j a  va  2s  .c  om*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_USERS, values, DBSchema.USER_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.USER_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}

From source file:com.rener.sea.DBHelper.java

private long setSyncFlowchart(JSONArray data) {
    SQLiteDatabase db = this.getWritableDatabase();
    int i = -1;/*from   w w w  .  ja  v a 2s .c o m*/
    try {
        for (i = 0; i < data.length(); i++) {
            JSONObject item = data.getJSONObject(i);
            ContentValues values = new ContentValues();
            values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO);
            db.update(DBSchema.TABLE_FLOWCHART, values, DBSchema.FLOWCHART_ID + " =? ",
                    new String[] { String.valueOf(item.getLong(DBSchema.FLOWCHART_ID)) });
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    db.close();
    return i;
}