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 87#253164477
    via GitHub by Mygod
  • Android database method was called twice
    via Stack Overflow by user4901016
  • Errors when running
    via Stack Overflow by Alexia White
  • Android Xml data parsing
    via Stack Overflow by hashim
  • sending attachment failed
    via GitHub by Safari77
    • android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId( at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId( at android.database.sqlite.SQLiteStatement.executeInsert( at android.database.sqlite.SQLiteDatabase.insertWithOnConflict( at android.database.sqlite.SQLiteDatabase.insert( at at at at at at$JobCallable.handleResult( at$JobCallable.runJob( at$ at$ at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at

    Users with the same issue

    24 times, last one,
    1 times, last one,
    Unknown UserUnknown User
    1 times, last one,
    Hiren AmaliyarHiren Amaliyar
    1 times, last one,
    Indri YunitaIndri Yunita
    20 times, last one,
    68 more bugmates