List of usage examples for android.database.sqlite SQLiteDatabase insertWithOnConflict
public long insertWithOnConflict(String table, String nullColumnHack, ContentValues initialValues, int conflictAlgorithm)
From source file:com.rener.sea.DBHelper.java
private long setUsers_specialization(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w. j a v a 2 s . c om*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.USERS_SPECIALIZATION_USER_ID)) values.put(DBSchema.USERS_SPECIALIZATION_USER_ID, item.getLong(DBSchema.USERS_SPECIALIZATION_USER_ID)); if (!item.isNull(DBSchema.USERS_SPECIALIZATION_SPECIALIZATION_ID)) values.put(DBSchema.USERS_SPECIALIZATION_SPECIALIZATION_ID, item.getString(DBSchema.USERS_SPECIALIZATION_SPECIALIZATION_ID)); db.insertWithOnConflict(DBSchema.TABLE_USERS_SPECIALIZATION, null, values, 5); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return -1; }
From source file:com.rener.sea.DBHelper.java
private long setItem(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w.ja va 2 s . com*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.ITEM_ID)) values.put(DBSchema.ITEM_ID, item.getLong(DBSchema.ITEM_ID)); if (!item.isNull(DBSchema.ITEM_LABEL)) values.put(DBSchema.ITEM_LABEL, item.getString(DBSchema.ITEM_LABEL)); if (!item.isNull(DBSchema.ITEM_FLOWCHART_ID)) values.put(DBSchema.ITEM_FLOWCHART_ID, item.getString(DBSchema.ITEM_FLOWCHART_ID)); if (!item.isNull(DBSchema.ITEM_TYPE)) values.put(DBSchema.ITEM_TYPE, item.getString(DBSchema.ITEM_TYPE)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_ITEM, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setLocation_category(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from w w w .j av a 2s. com try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.LOCATION_CATEGORY_LOCATION_ID)) values.put(DBSchema.LOCATION_CATEGORY_LOCATION_ID, item.getLong(DBSchema.LOCATION_CATEGORY_LOCATION_ID)); if (!item.isNull(DBSchema.LOCATION_CATEGORY_CATEGORY_ID)) values.put(DBSchema.LOCATION_CATEGORY_CATEGORY_ID, item.getLong(DBSchema.LOCATION_CATEGORY_CATEGORY_ID)); if (!item.isNull(DBSchema.STATUS)) values.put(DBSchema.STATUS, item.getString(DBSchema.STATUS)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_LOCATION_CATEGORY, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setPath(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from w w w . ja v a2 s. c om try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.PATH_REPORT_ID)) values.put(DBSchema.PATH_REPORT_ID, item.getLong(DBSchema.PATH_REPORT_ID)); if (!item.isNull(DBSchema.PATH_OPTION_ID)) values.put(DBSchema.PATH_OPTION_ID, item.getLong(DBSchema.PATH_OPTION_ID)); if (!item.isNull(DBSchema.PATH_DATA)) values.put(DBSchema.PATH_DATA, item.getString(DBSchema.PATH_DATA)); if (!item.isNull(DBSchema.PATH_SEQUENCE)) values.put(DBSchema.PATH_SEQUENCE, item.getLong(DBSchema.PATH_SEQUENCE)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_PATH, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setOption(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from www .j ava 2 s . co m try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.OPTION_ID)) values.put(DBSchema.OPTION_ID, item.getLong(DBSchema.OPTION_ID)); if (!item.isNull(DBSchema.OPTION_PARENT_ID)) values.put(DBSchema.OPTION_PARENT_ID, item.getLong(DBSchema.OPTION_PARENT_ID)); if (!item.isNull(DBSchema.OPTION_NEXT_ID)) values.put(DBSchema.OPTION_NEXT_ID, item.getLong(DBSchema.OPTION_NEXT_ID)); if (!item.isNull(DBSchema.OPTION_LABEL)) values.put(DBSchema.OPTION_LABEL, item.getString(DBSchema.OPTION_LABEL)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_OPTION, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setDevices(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w . j av a 2 s . c om*/ try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.DEVICE_ID)) values.put(DBSchema.DEVICE_ID, item.getLong(DBSchema.DEVICE_ID)); if (!item.isNull(DBSchema.DEVICE_NAME)) values.put(DBSchema.DEVICE_NAME, item.getString(DBSchema.DEVICE_NAME)); if (!item.isNull(DBSchema.DEVICE_ID_NUMBER)) values.put(DBSchema.DEVICE_ID_NUMBER, item.getLong(DBSchema.DEVICE_ID_NUMBER)); if (!item.isNull(DBSchema.DEVICE_USER_ID)) values.put(DBSchema.DEVICE_USER_ID, item.getLong(DBSchema.DEVICE_USER_ID)); // if(!item.isNull(DBSchema.DEVICE_LATEST_SYNC)) // values.put(DBSchema.DEVICE_LATEST_SYNC, item.getLong(DBSchema.DEVICE_LATEST_SYNC)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_DEVICES, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setAddress(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from w ww.jav a 2s .c om try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.ADDRESS_ID)) values.put(DBSchema.ADDRESS_ID, item.getLong(DBSchema.ADDRESS_ID)); if (!item.isNull(DBSchema.ADDRESS_LINE1)) values.put(DBSchema.ADDRESS_LINE1, item.getString(DBSchema.ADDRESS_LINE1)); if (!item.isNull(DBSchema.ADDRESS_CITY)) values.put(DBSchema.ADDRESS_CITY, item.getString(DBSchema.ADDRESS_CITY)); if (!item.isNull(DBSchema.ADDRESS_ZIPCODE)) values.put(DBSchema.ADDRESS_ZIPCODE, item.getString(DBSchema.ADDRESS_ZIPCODE)); if (!item.isNull(DBSchema.ADDRESS_LINE2)) values.put(DBSchema.ADDRESS_LINE2, item.getString(DBSchema.ADDRESS_LINE2)); if (!item.isNull(DBSchema.STATUS)) values.put(DBSchema.STATUS, item.getString(DBSchema.STATUS)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_ADDRESS, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setUsers(JSONArray data) { // Log.i(this.toString(), "USERS : " + data); SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/*from w w w . 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(); if (!item.isNull(DBSchema.USER_ID)) values.put(DBSchema.USER_ID, item.getLong(DBSchema.USER_ID)); if (!item.isNull(DBSchema.USER_USERNAME)) values.put(DBSchema.USER_USERNAME, item.getString(DBSchema.USER_USERNAME)); if (!item.isNull(DBSchema.USER_PASSHASH)) values.put(DBSchema.USER_PASSHASH, item.getString(DBSchema.USER_PASSHASH)); if (!item.isNull(DBSchema.USER_PERSON_ID)) values.put(DBSchema.USER_PERSON_ID, item.getLong(DBSchema.USER_PERSON_ID)); if (!item.isNull(DBSchema.USER_SALT)) values.put(DBSchema.USER_SALT, item.getString(DBSchema.USER_SALT)); if (!item.isNull(DBSchema.USER_TYPE)) values.put(DBSchema.USER_TYPE, item.getString(DBSchema.USER_TYPE)); if (!item.isNull(DBSchema.STATUS)) values.put(DBSchema.STATUS, item.getString(DBSchema.STATUS)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_USERS, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setFlowchart(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;//from ww w . ja va 2 s . co m try { for (i = 0; i < data.length(); i++) { JSONObject item = data.getJSONObject(i); ContentValues values = new ContentValues(); if (!item.isNull(DBSchema.FLOWCHART_ID)) values.put(DBSchema.FLOWCHART_ID, item.getLong(DBSchema.FLOWCHART_ID)); if (!item.isNull(DBSchema.FLOWCHART_FIRST_ID)) values.put(DBSchema.FLOWCHART_FIRST_ID, item.getString(DBSchema.FLOWCHART_FIRST_ID)); if (!item.isNull(DBSchema.FLOWCHART_NAME)) values.put(DBSchema.FLOWCHART_NAME, item.getString(DBSchema.FLOWCHART_NAME)); if (!item.isNull(DBSchema.FLOWCHART_END_ID)) values.put(DBSchema.FLOWCHART_END_ID, item.getLong(DBSchema.FLOWCHART_END_ID)); if (!item.isNull(DBSchema.FLOWCHART_CREATOR_ID)) values.put(DBSchema.FLOWCHART_CREATOR_ID, item.getString(DBSchema.FLOWCHART_CREATOR_ID)); if (!item.isNull(DBSchema.FLOWCHART_VERSION)) values.put(DBSchema.FLOWCHART_VERSION, item.getString(DBSchema.FLOWCHART_VERSION)); if (!item.isNull(DBSchema.STATUS)) values.put(DBSchema.STATUS, item.getString(DBSchema.STATUS)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_FLOWCHART, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }
From source file:com.rener.sea.DBHelper.java
private long setAppointments(JSONArray data) { SQLiteDatabase db = this.getWritableDatabase(); int i = -1;/* 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(); if (!item.isNull(DBSchema.APPOINTMENT_ID)) values.put(DBSchema.APPOINTMENT_ID, item.getLong(DBSchema.APPOINTMENT_ID)); if (!item.isNull(DBSchema.APPOINTMENT_DATE)) values.put(DBSchema.APPOINTMENT_DATE, item.getString(DBSchema.APPOINTMENT_DATE)); if (!item.isNull(DBSchema.APPOINTMENT_TIME)) values.put(DBSchema.APPOINTMENT_TIME, item.getString(DBSchema.APPOINTMENT_TIME)); if (!item.isNull(DBSchema.APPOINTMENT_REPORT_ID)) values.put(DBSchema.APPOINTMENT_REPORT_ID, item.getLong(DBSchema.APPOINTMENT_REPORT_ID)); if (!item.isNull(DBSchema.APPOINTMENT_PURPOSE)) values.put(DBSchema.APPOINTMENT_PURPOSE, item.getString(DBSchema.APPOINTMENT_PURPOSE)); if (!item.isNull(DBSchema.APPOINTMENT_MAKER_ID)) values.put(DBSchema.APPOINTMENT_MAKER_ID, item.getLong(DBSchema.APPOINTMENT_MAKER_ID)); if (!item.isNull(DBSchema.STATUS)) values.put(DBSchema.STATUS, item.getString(DBSchema.STATUS)); values.put(DBSchema.MODIFIED, DBSchema.MODIFIED_NO); db.insertWithOnConflict(DBSchema.TABLE_APPOINTMENTS, null, values, 5); } } catch (JSONException e) { e.printStackTrace(); } db.close(); return i; }