Home » Android » android – Getting Context in onCreate in SQLiteOpenHelper

android – Getting Context in onCreate in SQLiteOpenHelper

Posted by: admin June 15, 2020 Leave a comment

Questions:

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

How to&Answers:

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

Answer:

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.