public void sync(Child child) throws IOException, JSONException {
   child.setSynced(true);
   fluentRequest
       .path(String.format("/children/%s", child.getUniqueId()))
       .context(context)
       .param("child", child.toString());
   if (child.opt("current_photo_key") != null
       && !child.optString("current_photo_key").equals("")) {
     fluentRequest.param("current_photo_key", child.optString("current_photo_key"));
   }
   fluentRequest.put();
   repository.update(child);
 }
 private void saveIncomingChildren(ArrayList<String> idsToDownload)
     throws IOException, JSONException {
   for (String idToDownload : idsToDownload) {
     Child incomingChild = childService.getChild(idToDownload);
     if (isCancelled()) {
       break;
     }
     try {
       incomingChild.setSynced(true);
       if (childRepository.exists(incomingChild.getUniqueId())) {
         childRepository.update(incomingChild);
       } else {
         childRepository.createOrUpdate(incomingChild);
       }
       childService.setPhoto(incomingChild);
     } catch (Exception e) {
       Log.e("SyncAllDataTask", "Error syncing child", e);
       throw new RuntimeException(e);
     }
   }
 }