io.requery.sql.StatementExecutionException

tip

activity.OnCreate is executed every time the app launches or the screen is rotated, so, putting your DB initialization inside it will cause the DB to be called too many times causing the exception. Try to use the MyDatabase.onCreate method for this.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • GitHub comment 209#229767013
    via GitHub by dabx
    ,
  • GitHub comment 199#227340450
    via GitHub by danysz
    ,
  • Android sqlite ID not generated
    via Stack Overflow by Sadragos
    ,
  • sqlite: Android sqlite ID not generated
    via by Unknown author,
  • Create daily crashes the app
    via GitHub by franzejr
    ,
  • Crash - Saving Daily
    via GitHub by negue
    ,
  • GitHub comment 57#157201848
    via GitHub by franzejr
    ,
    • io.requery.sql.StatementExecutionException: Exception executing statement: insert into Event (code, colour, dayName, endTime, name, roomCode, roomDescription, staff, startTime, studentOwner, type, weeks) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) at io.requery.sql.EntityUpdateOperation$1.evaluate(EntityUpdateOperation.java:74) at io.requery.sql.EntityUpdateOperation$1.evaluate(EntityUpdateOperation.java:55) at io.requery.query.BaseScalar.value(BaseScalar.java:49) at io.requery.sql.EntityWriter.insert(EntityWriter.java:452) at io.requery.sql.EntityWriter.cascadeWrite(EntityWriter.java:926) at io.requery.sql.EntityWriter.updateInverseAssociation(EntityWriter.java:782) at io.requery.sql.EntityWriter.updateAssociations(EntityWriter.java:665) at io.requery.sql.EntityWriter.insert(EntityWriter.java:454) at io.requery.sql.EntityWriter.insert(EntityWriter.java:410) at io.requery.sql.EntityDataStore.insert(EntityDataStore.java:209) at io.requery.sql.EntityDataStore.insert(EntityDataStore.java:199) at io.requery.rx.SingleEntityStoreFromBlocking$1.get(SingleEntityStoreFromBlocking.java:87) at io.requery.rx.SingleOnSubscribeFromSupplier.call(SingleOnSubscribeFromSupplier.java:34) at io.requery.rx.SingleOnSubscribeFromSupplier.call(SingleOnSubscribeFromSupplier.java:23) at rx.Single$1.call(Single.java:94) at rx.Single$1.call(Single.java:74) at rx.Single.subscribe(Single.java:1822) at rx.Single.subscribe(Single.java:1899) at rx.Single$19$1.call(Single.java:1954) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at rx.internal.schedulers.ExecutorScheduler$ExecutorSchedulerWorker.run(ExecutorScheduler.java:104) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.sql.SQLIntegrityConstraintViolationException: android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787) at io.requery.android.sqlite.BaseConnection.throwSQLException(BaseConnection.java:69) at io.requery.android.sqlite.SqlitePreparedStatement.executeUpdate(SqlitePreparedStatement.java:164) at io.requery.sql.EntityUpdateOperation$1.evaluate(EntityUpdateOperation.java:69) ... 23 more Caused by: android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86) at io.requery.android.sqlite.SqlitePreparedStatement.executeUpdate(SqlitePreparedStatement.java:160) ... 24 more

    Users with the same issue

    deallocdealloc
    4 times, last one,
    jkjk
    2 times, last one,
    Hiren AmaliyarHiren Amaliyar
    1 times, last one,
    bayukresnobayukresno
    617 times, last one,
    xaviloxavilo
    1 times, last one,
    68 more bugmates