android.database.sqlite.SQLiteConstraintException: NOT NULL constraint failed: awards.key (code 1299)

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.

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.

  • Android database method was called twice
    via Stack Overflow by user4901016
  • Database crash
    via GitHub by gsczechowski
    • android.database.sqlite.SQLiteConstraintException: NOT NULL constraint failed: awards.key (code 1299) 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 com.thebluealliance.androidclient.database.ModelTable.add( at com.thebluealliance.androidclient.database.ModelTable.add( at com.thebluealliance.androidclient.database.writers.AwardListWriter.write( at com.thebluealliance.androidclient.gcm.notifications.AwardsPostedNotification.updateDataLocally( at com.thebluealliance.androidclient.gcm.GCMMessageHandler.handleMessage( at com.thebluealliance.androidclient.gcm.GCMMessageHandler.onHandleIntent( at$ServiceHandler.handleMessage( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at

    Users with the same issue

    mhicauber3 times, last one,
    lribeiro4 times, last one,
    Ajeet9 times, last one,
    Stefan Braune
    Stefan Braune9 times, last one,
    Bassiuz1 times, last one,
    68 more bugmates