SQLiteOpenHelper一个用于在数据库中每个表数据库中、SQLiteOpenHelper

2023-09-06 07:50:10 作者:小三注定输给小四

我开始开发一个应用程序,具有数据库功能,我有一个问题:

i'm starting to develop an app, with database functionality, i have a question:

是它最好是有一个大的 SQLiteOpenHelper 子类将定义的onCreate onUpgrade 的所有数据库中的表,或者最好是有很多 SQLiteOpenHelper ,每一个表,在这种情况下,辅助类会永远的读,然后就会有许多人呼吁为每个表,在 SQLiteOpenHelper

is it better to have a single big SQLiteOpenHelper subclass which will define the onCreate and onUpgrade for all the tables in the database, or is better to have many SQLiteOpenHelper, one for each table, in this case the helper class will be always readable and there will be many calls one for each table, at the SQLiteOpenHelper ?

至极一个是最好的做法是什么?或者是相同的,但有好有坏的副作用?

wich one is the best practice? or are the same but the have good and bad side effects?

推荐答案

您应该有一个SQLiteOpenHelper类的所有表格。检查这的链接。

You should have a single SQLiteOpenHelper class for all the tables. Check this link.