private void updateTask(Task task) { boolean needUpdate = false; Task remote = new Task(task); try { dbAccessor.getDbObject(task, task.getUuid()); } catch (InvalidKeyException e) { Log.d(TAG, "There are no local task " + task.getUuid()); needUpdate = true; } if (!needUpdate && remote.getGlobalUpdated() > task.getGlobalUpdated()) { needUpdate = true; Log.d(TAG, "Local task is too old - " + task.getUuid()); } if (needUpdate) { Log.d(TAG, "Should update task " + remote.getUuid()); dbAccessor.setDbObject(remote); } else { Log.d(TAG, "Should NOT update task " + remote.getUuid()); Log.d(TAG, "Local task - " + task.toString()); } }