Android Room SQLite_ERROR no such table

前端 未结 6 1002
旧巷少年郎
旧巷少年郎 2021-02-04 23:35

I\'m trying my hand at using Android Room and after following this tutorial I\'m getting the following error when i try to build the app:

Error:(23, 27) error: The

相关标签:
6条回答
  • 2021-02-05 00:15

    It helped me a lot to see the articles. I had this errorDatabase(entities = {Folder.class}, version = 1, exportSchema = false)

    just add my other class @Database(entities = {Folder.class, Urls.class}, version = 1, exportSchema = false)

    0 讨论(0)
  • 2021-02-05 00:20

    If you just added a new table, just update your Database class (That one class extending the RoomDatabase() class) and update the entities annotation

    @Database(entities = [User::class, NewTableHere::class], version = 1)
    abstract class AppDatabase : RoomDatabase() {
    

    Wish it saves you time on searching for answer, happy coding.

    0 讨论(0)
  • 2021-02-05 00:20

    my problem was with TABLE NAME :||| I wrote my table name In the wrong word :(((

    0 讨论(0)
  • 2021-02-05 00:28

    In my case, the cause of the problem was using the wrong table name. The table name I chose for my model class was different from the class name. I erroneously used the class name while querying my Data-Access-Object interface.

    @Query("SELECT * FROM tablename")
    

    Check your table name to make sure they match with the table name annotated into the model class.

    I hope this helps. Merry coding!

    0 讨论(0)
  • 2021-02-05 00:32

    Another reason for this error could be the entity is not listed in the AppDatabase.java file:

        @Database(entities = {XEntity.class, YEntity.class, ZEntity.class}, 
    version = 1, exportSchema = true)
    

    Make sure you have the latest db file in the databases folder, and if you export your schema, make sure your .json schema file under app\schemas is being properly updated.

    0 讨论(0)
  • 2021-02-05 00:36

    Room names tables the same as their associated entities. In your DAO, TABLE_ITEMS needs to be PermitItem, because your entity is PermitItem. Or, add the tableName property to the @Entity annotation, to tell Room some other name to use for the table.

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