How to use SQLiteOpenHelper without or less restrictive use of Context?

If you are extending SQLiteOpenHelper, you must use Context for the constructor. I am wondering if there is a way to leave this and work with database tables without context.

Or at least to be the least restrictive, I mean the project / class structure method that will make the story a few context transfers that I need to do now.

As my application has several levels of classes connected to each other, and there are several that connect to the database but have no influence on the interface, so they really don't need context.

Do you create your classes the way you pass context to them each time?

If not, how do you do this, how do you reuse context in a short class?

+5
source share
1 answer

I am wondering if there is a way to leave this and be able to work with database tables without Context.

Call openDatabase()on SQLiteDatabase.

Like my application has several class levels, chained in each other

Remember, this is the mobile phone for which you are developing. Too many layers of abstraction make performance difficult.

Do you create your classes in a path that you pass each time in context to them?

Sometimes yes, sometimes no.

, , ?

.

+3

All Articles