7

I'm trying to set my id field start to increment from 2018

@PrimaryKey(autoGenerate = true)
   @ColumnInfo(name = "id")
   private int id = 2018;
David Kathoh
  • 191
  • 1
  • 9
  • Check [this](https://stackoverflow.com/questions/44109700/how-to-make-primary-key-as-autoincrement-for-room-persistence-lib) – Praveen Rawat Apr 11 '18 at 12:44
  • Why? If you think that this will represent a year, SQLite can use whatever primary key values that it wants to assign. If you want particular values for the key, do not auto-generate the key, but instead use values that you specify. – CommonsWare Apr 11 '18 at 12:50
  • i want my user to remember their id easily @CommonsWare – David Kathoh Apr 11 '18 at 12:56
  • 1
    Then assign a primary key yourself, and do not use auto-generate. SQLite does not guarantee that auto-generated primary keys are easy to remember. – CommonsWare Apr 11 '18 at 12:57
  • @CommonsWare I get your point but not having possibility to at least exclude some values from autogenerated values is not cool. One of problems I see is that the very 1st entity to be created gets 0 - 0 sounds like some error value, it might as well come from not properly initialized primitives, see https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html. – Marian Paździoch Apr 15 '20 at 08:53
  • @MarianPaździoch: Then assign a primary key yourself, and do not use auto-generate. SQLite does not guarantee that auto-generated primary keys are not going to resemble some error value. – CommonsWare Apr 15 '20 at 11:55

0 Answers0