How to update sqlite_sequence table in Ormlite? I just need to update seq. How can I get this table through ORMLite?
EDIT
I cannot find the ORLite tool for this, so instead I use a simple SQL query. In my extends OrmLiteSqliteOpenHelper class, I use SQLiteDatabase to create this update.
EDIT2;)
In my project, I save the Lesson class and the WeekDefinition class.
class Lesson{ @DatabaseField(generatedId=true) private int id; ... } class WeekDefinitions{ @DatabaseField(generatedId=true) private int id; @DatabaseField(foreign=true, columnName="lesson_id") private Lesson lesson; ... }
Now, when I add new lessons, id increases. for example
id = 1 Math id = 2 English id = 3 Medicine
and in weekDefinition:
id = 1 lesson_id = 1 nr = 20 id = 2 lesson_id = 1 nr = 22 id = 3 lesson_id = 2 nr = 32 ... id = 12 lesson_id = 3 nr = 3
SQLite adds this row to sqlite_sequence (when using auto-increment)
rowId = 1 name = lesson seq = 3 rowId = 2 name = weekDefinition seq = 12
Now I delete all rows from the Lesson and WeekDefinition tables. After that, Lesson and WeekDef are empty, but sqlite_sequence is still the same. And this is a problem because the id in the table lesson starts with a value of 4 (seq from sqlite_sequence for the lesson and adds 1):
id = 4 Math id = 5 English id = 6 Medicine
and weekDefinition
id = 13 lesson_id = 1 nr = 20 id = 14 lesson_id = 1 nr = 22 id = 15 lesson_id = 2 nr = 32
and for lesson id = 4, Math I have to get weekDefinitios, but in weekDefinitions classes_id only has a value of 1 to 3. And this is my problem. I need a sqlite_sequence "reset" table (or is there a better solution?)
Bandzio
source share