Android/ORMLite Insert Row with ID
Posted
by
Joe M
on Stack Overflow
See other posts from Stack Overflow
or by Joe M
Published on 2011-08-16T05:23:35Z
Indexed on
2012/09/03
21:38 UTC
Read the original article
Hit count: 167
I'm currently using ORMLite to work with a SQLite database on Android. As part of this I am downloading a bunch of data from a backend server and I'd like to have this data added to the SQLite database in the exact same format it is on the backend server (ie the IDs are the same, etc).
So, my question to you is if I populate my database entry object (we'll call it Equipment), including Equipment's generatedId/primary key field via setId(), and I then run a DAO.create() with that Equipment entry will that ID be saved correctly? I tried it this way and it seems to me that this was not the case. If that is the case I will try again and look for other problems, but with the first few passes over the code I was not able to find one. So essentially, if I call DAO.create() on a database object with an ID set will that ID be sent to the database and if it is not, how can I insert a row with a primary key value already filled out?
Thanks!
© Stack Overflow or respective owner