SQLiteException: no such table exists

前端 未结 2 1695
無奈伤痛
無奈伤痛 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:53

    It works fine in my computer with your code. so I guess that you change the TABLE name during your development. and just run the program again with eclipse's RUN command. So the application was not a fresh install. but you don't implement the onUpgrade() correctly.

    to solve your problem you met quickly.

    1. uninstall the program with adb uninstall
    2. reinstall the program.
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题