更新时间:2023-02-09 11:18:43
当然,你可以。这只是你的助手一流的设计问题。您可以DB的名称只是传递给你的助手类的构造函数(连同所需的上下文
实例),而不是硬编码:
Of course, you can. It is just a matter of your Helper class design. You can just pass the name of DB to your Helper class constructor (along with required Context
instance) instead of hardcoding:
public class DBOpenHelper extends SQLiteOpenHelper {
public Helper(Context context, String dbName, int dbVersion) {
super(context, dbName, null, dbVersion);
}
...
}