简体   繁体   中英

How to make multiple multiple tables in room during run time of an app?

I am trying to make a Ledger app in which there would one base table which would contain the name, phone number etc and a table containing all list of transaction corresponding to a particular person. Now I don't know how many persons I would add so tables need to be created during run time. But how should I do that?

I even tried a second where I would keep the tranctionId column as a foreign key in the base table and use it as a primary key in another table where all transaction would be stored in a mutableListOf<>() but it showing an error that use type convertors .

Please tell how should proceed or if there is some other way for such cases.

so tables need to be created during run time

Sorry, but Room does not support that directly. You can call getOpenHelper() on your RoomDatabase and do that stuff manually if you want. A more conventional approach is to have one table for all persons, with a person's ID as being one column in that table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM