首页 > 解决方案 > 我在 android、RoomDatabase 中有一些问题。初级水平

问题描述

我从https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin/?fbclid=IwAR2JnEpU-U4oZ28qfapYCxhivfxGFb0yfoaXUKdrHxAInNDfCi4bmz6044M#0构建 myRoomDatabase 应用程序

现在,我想在我的应用程序中有两个表。一个表名是“word_table”,第二个表名是“word_save_time”。但我没有任何解决方案,这将帮助我在我的应用程序中添加第二个表名。谁能给我一条路,可以解决我的问题?

标签: androidkotlin

解决方案


您需要创建另一个带有Entity注释的类。所以它看起来像:

@Entity(tableName = "word_save_time")
class SaveTime(){}

从您提供的链接: Each @Entity class represents a SQLite table. Annotate your class declaration to indicate that it's an entity. You can specify the name of the table if you want it to be different from the name of the class. This names the table "word_table".


推荐阅读