Partial Update without the Overwrite Check

This method merges the data on the server with the key-value pairs sent from the client. You will send only key-value pairs you want to update from the client to the server. Note that you cannot delete the keys on the server with this method.

The data will be overwritten unconditionally regardless of if the data on the server is updated by other clients.

Here is the sample code:

  • // Instantiate a KiiObject.
    Uri objUri = Uri.parse("Set the URI of an existing KiiObject here");
    KiiObject object = KiiObject.createByUri(objUri);
    
    try {
      // Update key-value pairs.
      object.set("myid", 1);
      object.set("name", "John Doe Jr");
      object.set("email", "john_jr@example.com");
    
      // Save and partially update the KiiObject.
      // This method appends the key-value pairs generated locally
      // to the KiiObject on the server.
      object.save();
    } catch (AppException e) {
      // Handle the error.
    } catch (IOException e) {
      // Handle the error.
    }
  • // Instantiate a KiiObject.
    Uri objUri = Uri.parse("Set the URI of an existing KiiObject here");
    KiiObject object = KiiObject.createByUri(objUri);
    
    // Update key-value pairs.
    object.set("myid", 1);
    object.set("name", "John Doe Jr");
    object.set("email", "john_jr@example.com");
    
    // Save and partially update the KiiObject.
    // This method appends the key-value pairs generated locally
    // to the KiiObject on the server.
    object.save(new KiiObjectCallBack() {
      @Override
      public void onSaveCompleted(int token, KiiObject object, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
      }
    });

This is what is happening in the sample code:

  1. Prepare a KiiObject to update. In this sample code, we are creating a KiiObject with its URI (Replace the URI in the code with the real one when you are running the code).
  2. Set the key-value pairs to update.
  3. Execute the save() method to update the KiiObject. We are not using the overwrite check, so the update will be made unconditionally.

You do not need to execute the refresh() method when updating a KiiObject partially. If you execute the refresh() method, all key-value pairs on the server will be downloaded to the client. So, the update will be virtually the full update.

When you partially update a KiiObject, you cannot remove key-value pairs with the remove() method. This is because the local key-value pairs are merged with those on the server. Fully update the KiiObject to remove key-value pairs.