且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLiteOpenHelper不是要求的onCreate

更新时间:2023-11-19 13:39:28

在SQLiteOpenHelper的的onCreate的含义是它是一个活动的不同。在这里,'的onCreate'只调用一次,这是你创建数据库的第一次。你运行应用程序下一次,该数据库已经存在,所以不会叫的onCreate。你的对象级初始化应在构造函数中,而不是在做'的onCreate

In SQLiteOpenHelper, the meaning of 'onCreate' is different from what it is in an Activity. Here,'onCreate' is called only once, which is the first time you create the database. The next time you run the app, the database is already there, so it won't call 'onCreate'. Your object level initialization should be done in the constructor and not in 'onCreate'

要见'的onCreate被调用,可以手动删除数据库文件,或者干脆卸载应用程序。

To see 'onCreate' being called, either manually delete the db file, or simply uninstall the app.