UNIQUE constraint failed: Note._id(Sqlite code 1555),(OS error - 2:No such file or directory)

Samebug tips1

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.


Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web144

  • via GitHub by chenzj-king
  • via Stack Overflow by Sadragos
  • Stack trace

    • android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: Note._id(Sqlite code 1555),(OS error - 2:No such file or directory) 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 org.greenrobot.greendao.AbstractDao.insertInsideTx( at org.greenrobot.greendao.AbstractDao.executeInsert( at org.greenrobot.greendao.AbstractDao.insert( at com.dreamliner.greendaosample.ui.activity.main.MainActivity.onClick( at com.dreamliner.greendaosample.ui.activity.main.MainActivity_ViewBinding$1.doClick( at butterknife.internal.DebouncingOnClickListener.onClick( at android.view.View.performClick( at android.view.View$ at android.os.Handler.handleCallback( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke( at$ at

    Write tip

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

    Users with the same issue

    4 times, last one
    2 times, last one
    Hiren AmaliyarHiren Amaliyar
    617 times, last one
    68 more bugmates