How to make AUTO_INCREMENT on Android SQLite database?

后端 未结 4 1568
无人共我
无人共我 2020-12-15 19:01

Hey I want to create a database with an AUTO_INCREMENT column. But I don\'t know how to parse the value in the method insert. I just don\'t know what to parse to an AUTO_INC

4条回答
  •  不知归路
    2020-12-15 19:50

    You don't have to specifically write AUTO_INCREMENT as in MYSQL.

    Just have to define the primary key Field as _id INTEGER PRIMARY KEY.

    It will not work, if have define the Primary key field with INT when creating the table. It Should be INTEGER and thats it.

    When you don't pass any value for the primary key filed when inserting records, it will automatically increase the value to be a unique value( same way MYSQL AUTO_INCREMENT works )

提交回复
热议问题