1
I am trying to insert the same id that I get from the server database in the android database through sqlite, however, it is generating an id of its own, I am using auto increment in Primary key, I have tried to use Unique and tried not to declare anyone as Primary key, but error when trying to insert in the mobile bank, only works when I put Primary key, but generates autoincrement that does not need
It would be more convenient and safer to have a separate column, for example id_server to store the original id. Whether you like it or not, Sqlite will need its own index. You may not even declare Primary key, but either way internally Sqlite will have a primary column.
– Bacco
I thought so too, but I was trying not to do it that way
– Victor Siqueira
Declaring or not a primary column in Sqlite only changes whether the internal ID is associated with a "first name" column or not. If you really want to not have the "default" primary key, you have to define
WITHOUT ROWID
when creating the table, but then you need to define your own PK. TheAUTOINCREMENT
you can omit in the table creation, regardless of whether or not you have PK defined (even to save some resources).– Bacco
I’ll do it that way anyway, if someone comes up with another better solution... kkk
– Victor Siqueira
I don’t understand what could be better for what you’re asking. Basically the WITHOUT ROWID + its own PK must solve its own indices. And I honestly think that what you want to do is actually no better than letting DB have its own key, but then only you who are designing the application that really knows what’s best for your case.
– Bacco
is that I needed to keep a chunk of the server database, replicated exactly the same on android, because then the project will go ahead, so there are no problems for maintenance I was trying not to use another column, but I believe your solution is not bad no ;D
– Victor Siqueira