在Android中使用SQLiteOpenHelper创建DB的开始

在Android中使用SQLiteOpenHelper创建DB的开始,android,sqlite,sqliteopenhelper,Android,Sqlite,Sqliteopenhelper,我应该在使用SQliteOpenHelper创建DB表时准备一个空的DB inadvance吗? 从医生那里。对于SQLiteOpenHelper,它声明: public abstract void onCreate (SQLiteDatabase db) Called when the database is created for the first time. This is where the creation of tables and the initial population

我应该在使用SQliteOpenHelper创建DB表时准备一个空的DB inadvance吗? 从医生那里。对于SQLiteOpenHelper,它声明:

public abstract void onCreate (SQLiteDatabase db) 
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen.
这让我感到困惑: 1.何时创建数据库并触发onCreate方法? 2.如果数据库不存在,它是否会自动创建

感谢您审阅问题并帮助回复

当在手机存储器中找不到数据库时,将调用onCreate方法并创建数据库


如果数据库存在,但版本较旧,则会调用onUpgradeSQLiteDatabase数据库,int-oldVersion,int-newVersion

Hi Papaiatis,感谢您的快速响应!onCreate只能在DB创建时调用一次,而onUpgrade将在DB模式随时更改时调用,对吗?正如我所说,当手机上找不到所需的数据库时,onCreate将被调用。如果数据库的存在版本为1,并且如果您需要版本为2的相同数据库,则将调用onUpgrade方法。