List of usage examples for android.database.sqlite SQLiteStatement execute
public void execute()
From source file:com.ichi2.anki.SyncClient.java
private void mergeCardModels(String modelId, JSONArray cardModels) { ArrayList<String> ids = new ArrayList<String>(); AnkiDb ankiDB = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()); String sql = "INSERT OR REPLACE INTO cardModels (id, ordinal, modelId, name, description, active, qformat, " + "aformat, lformat, qedformat, aedformat, questionInAnswer, questionFontFamily, questionFontSize, " + "questionFontColour, questionAlign, answerFontFamily, answerFontSize, answerFontColour, answerAlign, " + "lastFontFamily, lastFontSize, lastFontColour, editQuestionFontFamily, editQuestionFontSize, " + "editAnswerFontFamily, editAnswerFontSize, allowEmptyAnswer, typeAnswer) " + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; SQLiteStatement statement = ankiDB.getDatabase().compileStatement(sql); int len = cardModels.length(); for (int i = 0; i < len; i++) { try {/*from w w w . j av a 2 s .c o m*/ JSONObject cardModel = cardModels.getJSONObject(i); // id String id = cardModel.getString("id"); statement.bindString(1, id); // ordinal statement.bindString(2, cardModel.getString("ordinal")); // modelId statement.bindLong(3, cardModel.getLong("modelId")); // name statement.bindString(4, cardModel.getString("name")); // description statement.bindString(5, cardModel.getString("description")); // active statement.bindLong(6, Utils.booleanToInt(cardModel.getBoolean("active"))); // qformat statement.bindString(7, cardModel.getString("qformat")); // aformat statement.bindString(8, cardModel.getString("aformat")); // lformat if (cardModel.isNull("lformat")) { statement.bindNull(9); } else { statement.bindString(9, cardModel.getString("lformat")); } // qedformat if (cardModel.isNull("qedformat")) { statement.bindNull(10); } else { statement.bindString(10, cardModel.getString("qedformat")); } // aedformat if (cardModel.isNull("aedformat")) { statement.bindNull(11); } else { statement.bindString(11, cardModel.getString("aedformat")); } // questionInAnswer statement.bindLong(12, Utils.booleanToInt(cardModel.getBoolean("questionInAnswer"))); // questionFontFamily statement.bindString(13, cardModel.getString("questionFontFamily")); // questionFontSize statement.bindString(14, cardModel.getString("questionFontSize")); // questionFontColour statement.bindString(15, cardModel.getString("questionFontColour")); // questionAlign statement.bindString(16, cardModel.getString("questionAlign")); // answerFontFamily statement.bindString(17, cardModel.getString("answerFontFamily")); // answerFontSize statement.bindString(18, cardModel.getString("answerFontSize")); // answerFontColour statement.bindString(19, cardModel.getString("answerFontColour")); // answerAlign statement.bindString(20, cardModel.getString("answerAlign")); // lastFontFamily statement.bindString(21, cardModel.getString("lastFontFamily")); // lastFontSize statement.bindString(22, cardModel.getString("lastFontSize")); // lastFontColour statement.bindString(23, cardModel.getString("lastFontColour")); // editQuestionFontFamily if (cardModel.isNull("editQuestionFontFamily")) { statement.bindNull(24); } else { statement.bindString(24, cardModel.getString("editQuestionFontFamily")); } // editQuestionFontSize if (cardModel.isNull("editQuestionFontSize")) { statement.bindNull(25); } else { statement.bindString(25, cardModel.getString("editQuestionFontSize")); } // editAnswerFontFamily if (cardModel.isNull("editAnswerFontFamily")) { statement.bindNull(26); } else { statement.bindString(26, cardModel.getString("editAnswerFontFamily")); } // editAnswerFontSize if (cardModel.isNull("editAnswerFontSize")) { statement.bindNull(27); } else { statement.bindString(27, cardModel.getString("editAnswerFontSize")); } // allowEmptyAnswer if (cardModel.isNull("allowEmptyAnswer")) { cardModel.put("allowEmptyAnswer", true); } statement.bindLong(28, Utils.booleanToInt(cardModel.getBoolean("allowEmptyAnswer"))); // typeAnswer statement.bindString(29, cardModel.getString("typeAnswer")); statement.execute(); ids.add(id); } catch (JSONException e) { Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage()); } } statement.close(); // Delete card models that were not returned by the server ArrayList<String> cardModelsIds = ankiDB.queryColumn(String.class, "SELECT id FROM cardModels WHERE modelId = " + modelId, 0); for (String cardModelId : cardModelsIds) { if (!ids.contains(cardModelId)) { mDeck.deleteCardModel(modelId, cardModelId); } } }
From source file:mobile.tiis.appv2.base.BackboneApplication.java
public void updateChildVaccinationEventVaccinationAppointment(ChildCollector childCollector) { Child child = childCollector.getChildEntity(); List<VaccinationEvent> vaccinationEvents = childCollector.getVeList(); List<VaccinationAppointment> vaccinationAppointments = childCollector.getVaList(); ContentValues childCV = new ContentValues(); DatabaseHandler db = getDatabaseInstance(); SQLiteDatabase db1 = db.getWritableDatabase(); db1.beginTransactionNonExclusive();/*from w ww.j av a2 s . co m*/ try { String sql0 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.CHILD + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.ChildColumns.ID + "," + SQLHandler.ChildColumns.BARCODE_ID + "," + SQLHandler.ChildColumns.FIRSTNAME1 + "," + SQLHandler.ChildColumns.FIRSTNAME2 + "," + SQLHandler.ChildColumns.LASTNAME1 + "," + SQLHandler.ChildColumns.BIRTHDATE + "," + SQLHandler.ChildColumns.GENDER + "," + SQLHandler.ChildColumns.TEMP_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY + "," + SQLHandler.ChildColumns.DOMICILE + "," + SQLHandler.ChildColumns.DOMICILE_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY_ID + "," + SQLHandler.ChildColumns.STATUS_ID + "," + SQLHandler.ChildColumns.BIRTHPLACE_ID + "," + SQLHandler.ChildColumns.NOTES + "," + SQLHandler.ChildColumns.STATUS + "," + SQLHandler.ChildColumns.MOTHER_FIRSTNAME + "," + SQLHandler.ChildColumns.MOTHER_LASTNAME + "," + SQLHandler.ChildColumns.CUMULATIVE_SERIAL_NUMBER + "," + SQLHandler.ChildColumns.CHILD_REGISTRY_YEAR + "," + SQLHandler.ChildColumns.MOTHER_TT2_STS + "," + SQLHandler.ChildColumns.MOTHER_VVU_STS + "," + SQLHandler.ChildColumns.PHONE + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; SQLiteStatement stmt0 = db1.compileStatement(sql0); stmt0.bindString(1, "1"); stmt0.bindString(2, child.getId() == null ? "" : child.getId()); stmt0.bindString(3, child.getBarcodeID() == null ? "" : child.getBarcodeID()); stmt0.bindString(4, child.getFirstname1() == null ? "" : child.getFirstname1()); stmt0.bindString(5, child.getFirstname2() == null ? "" : child.getFirstname2()); stmt0.bindString(6, child.getLastname1() == null ? "" : child.getLastname1()); stmt0.bindString(7, child.getBirthdate() == null ? "" : child.getBirthdate()); stmt0.bindString(8, child.getGender() == null ? "" : child.getGender()); stmt0.bindString(9, child.getTempId() == null ? "" : child.getTempId()); stmt0.bindString(10, child.getHealthcenter() == null ? "" : child.getHealthcenter()); stmt0.bindString(11, child.getDomicile() == null ? "" : child.getDomicile()); stmt0.bindString(12, child.getDomicileId() == null ? "" : child.getDomicileId()); stmt0.bindString(13, child.getHealthcenterId() == null ? "" : child.getHealthcenterId()); stmt0.bindString(14, child.getStatusId() == null ? "" : child.getStatusId()); stmt0.bindString(15, child.getBirthplaceId() == null ? "" : child.getBirthplaceId()); stmt0.bindString(16, child.getNotes() == null ? "" : child.getNotes()); stmt0.bindString(17, child.getStatus() == null ? "" : child.getStatus()); stmt0.bindString(18, child.getMotherFirstname() == null ? "" : child.getMotherFirstname()); stmt0.bindString(19, child.getMotherLastname() == null ? "" : child.getMotherLastname()); stmt0.bindString(20, child.getChildCumulativeSn() == null ? "" : child.getChildCumulativeSn()); stmt0.bindString(21, child.getChildRegistryYear() == null ? "" : child.getChildRegistryYear()); stmt0.bindString(22, child.getMotherTT2Status() == null ? "" : child.getMotherTT2Status()); stmt0.bindString(23, child.getMotherHivStatus() == null ? "" : child.getMotherHivStatus()); stmt0.bindString(24, child.getPhone() == null ? "" : child.getPhone()); stmt0.execute(); stmt0.clearBindings(); String sql = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_EVENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationEventColumns.APPOINTMENT_ID + "," + SQLHandler.VaccinationEventColumns.CHILD_ID + "," + SQLHandler.VaccinationEventColumns.DOSE_ID + "," + SQLHandler.VaccinationEventColumns.HEALTH_FACILITY_ID + "," + SQLHandler.VaccinationEventColumns.ID + "," + SQLHandler.VaccinationEventColumns.IS_ACTIVE + "," + SQLHandler.VaccinationEventColumns.MODIFIED_BY + "," + SQLHandler.VaccinationEventColumns.MODIFIED_ON + "," + SQLHandler.VaccinationEventColumns.NONVACCINATION_REASON_ID + "," + SQLHandler.VaccinationEventColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_STATUS + "," + SQLHandler.VaccinationEventColumns.VACCINE_LOT_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; SQLiteStatement stmt = db1.compileStatement(sql); for (VaccinationEvent vaccinationEvent : vaccinationEvents) { stmt.bindString(1, "1"); stmt.bindString(2, vaccinationEvent.getAppointmentId()); stmt.bindString(3, vaccinationEvent.getChildId()); stmt.bindString(4, vaccinationEvent.getDoseId()); stmt.bindString(5, vaccinationEvent.getHealthFacilityId()); stmt.bindString(6, vaccinationEvent.getId()); stmt.bindString(7, vaccinationEvent.getIsActive()); stmt.bindString(8, vaccinationEvent.getModifiedBy()); stmt.bindString(9, vaccinationEvent.getModifiedOn()); stmt.bindString(10, vaccinationEvent.getNonvaccinationReasonId()); stmt.bindString(11, vaccinationEvent.getScheduledDate()); stmt.bindString(12, vaccinationEvent.getVaccinationDate()); stmt.bindString(13, vaccinationEvent.getVaccinationStatus()); stmt.bindString(14, vaccinationEvent.getVaccineLotId()); stmt.execute(); stmt.clearBindings(); } String sql1 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_APPOINTMENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationAppointmentColumns.CHILD_ID + "," + SQLHandler.VaccinationAppointmentColumns.ID + "," + SQLHandler.VaccinationAppointmentColumns.IS_ACTIVE + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_BY + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_ON + "," + SQLHandler.VaccinationAppointmentColumns.NOTES + "," + SQLHandler.VaccinationAppointmentColumns.OUTREACH + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_FACILITY_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?,?)"; SQLiteStatement stmt1 = db1.compileStatement(sql1); for (VaccinationAppointment vaccinationAppointment : vaccinationAppointments) { stmt1.bindString(1, "1"); stmt1.bindString(2, vaccinationAppointment.getChildId()); stmt1.bindString(3, vaccinationAppointment.getId()); stmt1.bindString(4, vaccinationAppointment.getIsActive()); stmt1.bindString(5, vaccinationAppointment.getModifiedBy()); stmt1.bindString(6, vaccinationAppointment.getModifiedOn()); stmt1.bindString(7, vaccinationAppointment.getNotes()); stmt1.bindString(8, vaccinationAppointment.getOutreach()); stmt1.bindString(9, vaccinationAppointment.getScheduledDate()); stmt1.bindString(10, vaccinationAppointment.getScheduledFacilityId()); stmt1.execute(); stmt1.clearBindings(); } db1.setTransactionSuccessful(); db1.endTransaction(); } catch (Exception e) { db1.endTransaction(); e.printStackTrace(); } }
From source file:mobile.tiis.appv2.base.BackboneApplication.java
/** * method used to add child, vaccination appointments and vaccination events into the database * * @param childCollector//from w w w . ja v a2s. c om */ public void addChildVaccinationEventVaccinationAppointment(ChildCollector childCollector) { Child child = childCollector.getChildEntity(); List<VaccinationEvent> vaccinationEvents = childCollector.getVeList(); List<VaccinationAppointment> vaccinationAppointments = childCollector.getVaList(); ContentValues childCV = new ContentValues(); DatabaseHandler db = getDatabaseInstance(); SQLiteDatabase db1 = db.getWritableDatabase(); db1.beginTransactionNonExclusive(); try { String sql0 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.CHILD + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.ChildColumns.ID + "," + SQLHandler.ChildColumns.BARCODE_ID + "," + SQLHandler.ChildColumns.FIRSTNAME1 + "," + SQLHandler.ChildColumns.FIRSTNAME2 + "," + SQLHandler.ChildColumns.LASTNAME1 + "," + SQLHandler.ChildColumns.BIRTHDATE + "," + SQLHandler.ChildColumns.GENDER + "," + SQLHandler.ChildColumns.TEMP_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY + "," + SQLHandler.ChildColumns.DOMICILE + "," + SQLHandler.ChildColumns.DOMICILE_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY_ID + "," + SQLHandler.ChildColumns.STATUS_ID + "," + SQLHandler.ChildColumns.BIRTHPLACE_ID + "," + SQLHandler.ChildColumns.NOTES + "," + SQLHandler.ChildColumns.STATUS + "," + SQLHandler.ChildColumns.MOTHER_FIRSTNAME + "," + SQLHandler.ChildColumns.MOTHER_LASTNAME + "," + SQLHandler.ChildColumns.CUMULATIVE_SERIAL_NUMBER + "," + SQLHandler.ChildColumns.CHILD_REGISTRY_YEAR + "," + SQLHandler.ChildColumns.MOTHER_TT2_STS + "," + SQLHandler.ChildColumns.MOTHER_VVU_STS + "," + SQLHandler.ChildColumns.PHONE + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; SQLiteStatement stmt0 = db1.compileStatement(sql0); stmt0.bindString(1, "1"); stmt0.bindString(2, child.getId() == null ? "" : child.getId()); stmt0.bindString(3, child.getBarcodeID() == null ? "" : child.getBarcodeID()); stmt0.bindString(4, child.getFirstname1() == null ? "" : child.getFirstname1()); stmt0.bindString(5, child.getFirstname2() == null ? "" : child.getFirstname2()); stmt0.bindString(6, child.getLastname1() == null ? "" : child.getLastname1()); stmt0.bindString(7, child.getBirthdate() == null ? "" : child.getBirthdate()); stmt0.bindString(8, child.getGender() == null ? "" : child.getGender()); stmt0.bindString(9, child.getTempId() == null ? "" : child.getTempId()); stmt0.bindString(10, child.getHealthcenter() == null ? "" : child.getHealthcenter()); stmt0.bindString(11, child.getDomicile() == null ? "" : child.getDomicile()); stmt0.bindString(12, child.getDomicileId() == null ? "" : child.getDomicileId()); stmt0.bindString(13, child.getHealthcenterId() == null ? "" : child.getHealthcenterId()); stmt0.bindString(14, child.getStatusId() == null ? "" : child.getStatusId()); stmt0.bindString(15, child.getBirthplaceId() == null ? "" : child.getBirthplaceId()); stmt0.bindString(16, child.getNotes() == null ? "" : child.getNotes()); stmt0.bindString(17, child.getStatus() == null ? "" : child.getStatus()); stmt0.bindString(18, child.getMotherFirstname() == null ? "" : child.getMotherFirstname()); stmt0.bindString(19, child.getMotherLastname() == null ? "" : child.getMotherLastname()); stmt0.bindString(20, child.getChildCumulativeSn() == null ? "" : child.getChildCumulativeSn()); stmt0.bindString(21, child.getChildRegistryYear() == null ? "" : child.getChildRegistryYear()); stmt0.bindString(22, child.getMotherTT2Status() == null ? "" : child.getMotherTT2Status()); stmt0.bindString(23, child.getMotherHivStatus() == null ? "" : child.getMotherHivStatus()); stmt0.bindString(24, child.getPhone() == null ? "" : child.getPhone()); stmt0.execute(); stmt0.clearBindings(); String sql = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_EVENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationEventColumns.APPOINTMENT_ID + "," + SQLHandler.VaccinationEventColumns.CHILD_ID + "," + SQLHandler.VaccinationEventColumns.DOSE_ID + "," + SQLHandler.VaccinationEventColumns.HEALTH_FACILITY_ID + "," + SQLHandler.VaccinationEventColumns.ID + "," + SQLHandler.VaccinationEventColumns.IS_ACTIVE + "," + SQLHandler.VaccinationEventColumns.MODIFIED_BY + "," + SQLHandler.VaccinationEventColumns.MODIFIED_ON + "," + SQLHandler.VaccinationEventColumns.NONVACCINATION_REASON_ID + "," + SQLHandler.VaccinationEventColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_STATUS + "," + SQLHandler.VaccinationEventColumns.VACCINE_LOT_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; SQLiteStatement stmt = db1.compileStatement(sql); for (VaccinationEvent vaccinationEvent : vaccinationEvents) { stmt.bindString(1, "1"); stmt.bindString(2, vaccinationEvent.getAppointmentId()); stmt.bindString(3, vaccinationEvent.getChildId()); stmt.bindString(4, vaccinationEvent.getDoseId()); stmt.bindString(5, vaccinationEvent.getHealthFacilityId()); stmt.bindString(6, vaccinationEvent.getId()); stmt.bindString(7, vaccinationEvent.getIsActive()); stmt.bindString(8, vaccinationEvent.getModifiedBy()); stmt.bindString(9, vaccinationEvent.getModifiedOn()); stmt.bindString(10, vaccinationEvent.getNonvaccinationReasonId()); stmt.bindString(11, vaccinationEvent.getScheduledDate()); stmt.bindString(12, vaccinationEvent.getVaccinationDate()); stmt.bindString(13, vaccinationEvent.getVaccinationStatus()); stmt.bindString(14, vaccinationEvent.getVaccineLotId()); stmt.execute(); stmt.clearBindings(); } String sql1 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_APPOINTMENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationAppointmentColumns.CHILD_ID + "," + SQLHandler.VaccinationAppointmentColumns.ID + "," + SQLHandler.VaccinationAppointmentColumns.IS_ACTIVE + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_BY + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_ON + "," + SQLHandler.VaccinationAppointmentColumns.NOTES + "," + SQLHandler.VaccinationAppointmentColumns.OUTREACH + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_FACILITY_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?,?)"; SQLiteStatement stmt1 = db1.compileStatement(sql1); for (VaccinationAppointment vaccinationAppointment : vaccinationAppointments) { stmt1.bindString(1, "1"); stmt1.bindString(2, vaccinationAppointment.getChildId()); stmt1.bindString(3, vaccinationAppointment.getId()); stmt1.bindString(4, vaccinationAppointment.getIsActive()); stmt1.bindString(5, vaccinationAppointment.getModifiedBy()); stmt1.bindString(6, vaccinationAppointment.getModifiedOn()); stmt1.bindString(7, vaccinationAppointment.getNotes()); stmt1.bindString(8, vaccinationAppointment.getOutreach()); stmt1.bindString(9, vaccinationAppointment.getScheduledDate()); stmt1.bindString(10, vaccinationAppointment.getScheduledFacilityId()); stmt1.execute(); stmt1.clearBindings(); } db1.setTransactionSuccessful(); db1.endTransaction(); } catch (Exception e) { db1.endTransaction(); e.printStackTrace(); } }
From source file:mobile.tiis.appv2.base.BackboneApplication.java
public boolean addChildVaccinationEventVaccinationAppointment(ChildCollector2 childCollector) { Log.d("coze", "saving data to db"); boolean containsData = false; List<Child> children = childCollector.getChildList(); List<VaccinationEvent> vaccinationEvents = childCollector.getVeList(); List<VaccinationAppointment> vaccinationAppointments = childCollector.getVaList(); DatabaseHandler db = getDatabaseInstance(); SQLiteDatabase db1 = db.getWritableDatabase(); db1.beginTransactionNonExclusive();// w w w . j a v a 2 s . co m try { if (children != null) { String sql0 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.CHILD + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.ChildColumns.ID + "," + SQLHandler.ChildColumns.BARCODE_ID + "," + SQLHandler.ChildColumns.FIRSTNAME1 + "," + SQLHandler.ChildColumns.FIRSTNAME2 + "," + SQLHandler.ChildColumns.LASTNAME1 + "," + SQLHandler.ChildColumns.BIRTHDATE + "," + SQLHandler.ChildColumns.GENDER + "," + SQLHandler.ChildColumns.TEMP_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY + "," + SQLHandler.ChildColumns.DOMICILE + "," + SQLHandler.ChildColumns.DOMICILE_ID + "," + SQLHandler.ChildColumns.HEALTH_FACILITY_ID + "," + SQLHandler.ChildColumns.STATUS_ID + "," + SQLHandler.ChildColumns.BIRTHPLACE_ID + "," + SQLHandler.ChildColumns.NOTES + "," + SQLHandler.ChildColumns.STATUS + "," + SQLHandler.ChildColumns.MOTHER_FIRSTNAME + "," + SQLHandler.ChildColumns.MOTHER_LASTNAME + "," + SQLHandler.ChildColumns.PHONE + "," + SQLHandler.ChildColumns.CUMULATIVE_SERIAL_NUMBER + "," + SQLHandler.ChildColumns.CHILD_REGISTRY_YEAR + "," + SQLHandler.ChildColumns.MOTHER_VVU_STS + "," + SQLHandler.ChildColumns.MOTHER_TT2_STS + "," + SQLHandler.ChildColumns.MODIFIED_ON + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?)"; SQLiteStatement stmt0 = db1.compileStatement(sql0); for (Child child : children) { containsData = true; stmt0.bindString(1, "1"); stmt0.bindString(2, child.getId() == null ? "" : child.getId()); stmt0.bindString(3, child.getBarcodeID() == null ? "" : child.getBarcodeID()); stmt0.bindString(4, child.getFirstname1() == null ? "" : child.getFirstname1()); stmt0.bindString(5, child.getFirstname2() == null ? "" : child.getFirstname2()); stmt0.bindString(6, child.getLastname1() == null ? "" : child.getLastname1()); stmt0.bindString(7, child.getBirthdate() == null ? "" : child.getBirthdate()); stmt0.bindString(8, child.getGender() == null ? "" : child.getGender()); stmt0.bindString(9, child.getTempId() == null ? "" : child.getTempId()); stmt0.bindString(10, child.getHealthcenter() == null ? "" : child.getHealthcenter()); stmt0.bindString(11, child.getDomicile() == null ? "" : child.getDomicile()); stmt0.bindString(12, child.getDomicileId() == null ? "" : child.getDomicileId()); stmt0.bindString(13, child.getHealthcenterId() == null ? "" : child.getHealthcenterId()); stmt0.bindString(14, child.getStatusId() == null ? "" : child.getStatusId()); stmt0.bindString(15, child.getBirthplaceId() == null ? "" : child.getBirthplaceId()); stmt0.bindString(16, child.getNotes() == null ? "" : child.getNotes()); stmt0.bindString(17, child.getDomicile() == null ? "" : child.getDomicile()); stmt0.bindString(18, child.getMotherFirstname() == null ? "" : child.getMotherFirstname()); stmt0.bindString(19, child.getMotherLastname() == null ? "" : child.getMotherLastname()); stmt0.bindString(20, child.getPhone() == null ? "" : child.getPhone()); stmt0.bindString(21, child.getChildCumulativeSn() == null ? "" : child.getChildCumulativeSn()); stmt0.bindString(22, child.getChildRegistryYear() == null ? "" : child.getChildRegistryYear()); stmt0.bindString(23, child.getMotherHivStatus() == null ? "" : child.getMotherHivStatus()); stmt0.bindString(24, child.getMotherTT2Status() == null ? "" : child.getMotherTT2Status()); stmt0.bindString(25, child.getModifiedOn() == null ? "" : child.getModifiedOn()); stmt0.execute(); stmt0.clearBindings(); } } if (vaccinationEvents != null) { String sql = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_EVENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationEventColumns.APPOINTMENT_ID + "," + SQLHandler.VaccinationEventColumns.CHILD_ID + "," + SQLHandler.VaccinationEventColumns.DOSE_ID + "," + SQLHandler.VaccinationEventColumns.HEALTH_FACILITY_ID + "," + SQLHandler.VaccinationEventColumns.ID + "," + SQLHandler.VaccinationEventColumns.IS_ACTIVE + "," + SQLHandler.VaccinationEventColumns.MODIFIED_BY + "," + SQLHandler.VaccinationEventColumns.MODIFIED_ON + "," + SQLHandler.VaccinationEventColumns.NONVACCINATION_REASON_ID + "," + SQLHandler.VaccinationEventColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_DATE + "," + SQLHandler.VaccinationEventColumns.VACCINATION_STATUS + "," + SQLHandler.VaccinationEventColumns.VACCINE_LOT_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; SQLiteStatement stmt = db1.compileStatement(sql); for (VaccinationEvent vaccinationEvent : vaccinationEvents) { containsData = true; stmt.bindString(1, "1"); stmt.bindString(2, vaccinationEvent.getAppointmentId()); stmt.bindString(3, vaccinationEvent.getChildId()); stmt.bindString(4, vaccinationEvent.getDoseId()); stmt.bindString(5, vaccinationEvent.getHealthFacilityId()); stmt.bindString(6, vaccinationEvent.getId()); stmt.bindString(7, vaccinationEvent.getIsActive()); stmt.bindString(8, vaccinationEvent.getModifiedBy()); stmt.bindString(9, vaccinationEvent.getModifiedOn()); stmt.bindString(10, vaccinationEvent.getNonvaccinationReasonId()); stmt.bindString(11, vaccinationEvent.getScheduledDate()); stmt.bindString(12, vaccinationEvent.getVaccinationDate()); stmt.bindString(13, vaccinationEvent.getVaccinationStatus()); stmt.bindString(14, vaccinationEvent.getVaccineLotId()); stmt.execute(); stmt.clearBindings(); } } if (vaccinationAppointments != null) { String sql1 = "INSERT OR REPLACE INTO " + SQLHandler.Tables.VACCINATION_APPOINTMENT + " ( " + SQLHandler.SyncColumns.UPDATED + ", " + SQLHandler.VaccinationAppointmentColumns.CHILD_ID + "," + SQLHandler.VaccinationAppointmentColumns.ID + "," + SQLHandler.VaccinationAppointmentColumns.IS_ACTIVE + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_BY + "," + SQLHandler.VaccinationAppointmentColumns.MODIFIED_ON + "," + SQLHandler.VaccinationAppointmentColumns.NOTES + "," + SQLHandler.VaccinationAppointmentColumns.OUTREACH + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_DATE + "," + SQLHandler.VaccinationAppointmentColumns.SCHEDULED_FACILITY_ID + " ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?,?)"; SQLiteStatement stmt1 = db1.compileStatement(sql1); for (VaccinationAppointment vaccinationAppointment : vaccinationAppointments) { containsData = true; stmt1.bindString(1, "1"); stmt1.bindString(2, vaccinationAppointment.getChildId()); stmt1.bindString(3, vaccinationAppointment.getId()); stmt1.bindString(4, vaccinationAppointment.getIsActive()); stmt1.bindString(5, vaccinationAppointment.getModifiedBy()); stmt1.bindString(6, vaccinationAppointment.getModifiedOn()); stmt1.bindString(7, vaccinationAppointment.getNotes()); stmt1.bindString(8, vaccinationAppointment.getOutreach()); stmt1.bindString(9, vaccinationAppointment.getScheduledDate()); stmt1.bindString(10, vaccinationAppointment.getScheduledFacilityId()); Log.d("day20", "Out Reach for " + vaccinationAppointment.getChildId() + " is : " + vaccinationAppointment.getOutreach()); stmt1.execute(); stmt1.clearBindings(); } } db1.setTransactionSuccessful(); db1.endTransaction(); } catch (Exception e) { try { db1.endTransaction(); } catch (Exception e1) { e1.printStackTrace(); } e.printStackTrace(); } Log.d("coze", "saving data to db returning = " + containsData); return containsData; }