title: realm - update object with method createOrUpdateAllFromJson
body: <p>I have an object which has three fields in the json, and one of my own field</p>
  
  <pre><code>  public class partner extends RealmObject {
          @PrimaryKey
          @SerializedName("id")
          private int id;
  
          @SerializedName("name")
          private String name;
  
          @SerializedName("subtitle")
          private String subtitle;
  
          private int testInt;
      }
  </code></pre>
  
  <p>This is small example json</p>
  
  <pre><code>[{
  "id":1,
  "name":"test1",
  "subtitle":"test2",
  }]
  </code></pre>
  
  <p>I save the value in field "testInt", so</p>
  
  <pre><code>Realm realm = Realm.getDefaultInstance();
  realm.beginTransaction();
  hPartner.setTestInt(6);
  realm.commitTransaction();
  </code></pre>
  
  <p>I create/update an object by using code. </p>
  
  <pre><code>realm.createOrUpdateAllFromJson(partner.class, new ByteArrayInputStream(str.getBytes(Charset.forName("UTF-8"))));
  </code></pre>
  
  <p>And it all works. 
  But value is stored in the field "testInt" is cleared. After the update, I see the value zero. (but must see the value 6)</p>
  
  <p>What should I do to the value in the field "testInt" does not delete?</p>
  
  <p><strong>UPDATE</strong>
  My data is updated every time when application starts.
  And I have made the following test (this code is only for test).
  This code runs at startup app</p>
  
  <pre><code>    realm.beginTransaction();
      realm.createOrUpdateAllFromJson(partner.class, new ByteArrayInputStream(jsonData.getBytes(Charset.forName("UTF-8"))));
      realm.commitTransaction();
  
      realm.beginTransaction();
      partner partner = realm.where(partner.class).findFirst();
      partner.setTestInt(6);
      realm.commitTransaction();
  
      realm.beginTransaction();
      realm.createOrUpdateAllFromJson(partner.class, new ByteArrayInputStream(jsonData.getBytes(Charset.forName("UTF-8"))));
      realm.commitTransaction();
  
      partner = realm.where(partner.class).findFirst();
  </code></pre>
  
  <p>In the latter the object "partner" value is stored.And it works!</p>
  
  <p>But if I restarted the application and check the first object "partner" value "testInt" is cleared. Somewhere there is an error or bug.</p>
  
  <p><strong>UPDATE2</strong>
  found the bad code that deletes all records. My mistake
  realm.where(partner.class).findAll().deleteAllFromRealm();</p>