title: update Realm table only if Record is new (Java)
body: <p>I am trying to update my table only if a record is new (doesn't exists yet on my stored table by checking record's objectId ) my objectId is primary key. I tried to add condition  <code>realm.where(NotesRealmClass.class).notEqualTo(&quot;objectId&quot;, Id);</code>
  but it didn't seems to work how can i add a record only if record is new or we can say - stop updating the previously stored records</p>
  <pre><code>public void storeNotes( String Id, String Title ,String Location) {
  
      realm.beginTransaction();
      NotesRealmClass Notes = new NotesRealmClass();
      Notes.setobjectId(Id);
      Notes.setLocation(Location);
      Notes.setTitle(Title);
      realm.where(NotesRealmClass.class).notEqualTo(&quot;objectId&quot;, Id); // i tired to check if we already have the object with object Id 
      realm.copyToRealmOrUpdate(Notes);
      Toast.makeText(context, &quot;Notes Stored&quot;, Toast.LENGTH_SHORT).show();
      realm.commitTransaction();
  
  }
  </code></pre>