开发者

Getting Context in onCreate in SQLiteOpenHelper

开发者 https://www.devze.com 2023-03-12 18:51 出处:网络
In my android app: How can I get开发者_Python百科 access to Context in the onCreate method of the SQLiteOpenHelper?You extend SQLiteOpenHelper and in your own constructor, save it to a field. Then, la

In my android app: How can I get开发者_Python百科 access to Context in the onCreate method of the SQLiteOpenHelper?


You extend SQLiteOpenHelper and in your own constructor, save it to a field. Then, later, in onCreate() you have access to the context.


You can extend that class and pass the context to the constructor, which stores it inside a variable. You then can access it from within the onCreate method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号