SQLiteException: no such table exists

前端 未结 2 1698
無奈伤痛
無奈伤痛 2021-01-16 18:16

I am trying to create a SQLite database within my android app, but my code consistently throws a \"SQLiteException\" saying that no such table exists. I am new to SQL, but I

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 18:59

    Have you made changes to the table after you initially created it (meaning run it on your phone/emulator)? Like maybe adding a new table, or changing the name of it?

    If so, you need to change your DATABASE_VERSION to 2 so that the database will be upgraded to your latest schema.

    And KEY_FAVORITE + " bit, " needs to be KEY_FAVORITE + " integer, ". And if you make that change, you need to update your DATABASE_VERSION too.

    Basically for anything that makes a change to the structure of the database you need to increase the version so the database will re-create the database with your new changes.

提交回复
热议问题