yydl
yydl

Reputation: 24474

Getting Context in onCreate in SQLiteOpenHelper

In my android app: How can I get access to Context in the onCreate method of the SQLiteOpenHelper?

Upvotes: 8

Views: 4130

Answers (2)

Will Kru
Will Kru

Reputation: 5212

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.

Upvotes: 1

Steve Prentice
Steve Prentice

Reputation: 23514

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

Upvotes: 8

Related Questions