title: Android Room - Autogenerate Primary Key
body: <p>I'm having an issue that I can't find any documentation for with Room for Android and auto generating the primary key.</p>
  
  <p>I've got an entity class that looks sort of like this:</p>
  
  <pre><code>@Entity
  public class Preference {
  
      @PrimaryKey(autoGenerate = true)
      private int id;
  
      public void setId(int id) {
  
          this.id = id;
  
      }
  
  }
  </code></pre>
  
  <p>This is working fine when I've set the id manually but when I don't set the primary key I'm getting an error regarding the primary key being null. Looking at the autogenerated file I can't see anywhere that it would auto increment the primary key.</p>
  
  <p>So I guess my question is this: can you auto generate a primary key of a private member with a setter or would I need to manually auto generate my key in the setter?</p>