views:

205

answers:

1

If you extend SQLiteOpenHelper, for the Constructor you have to use a Context. I am wondering if there is a way to leave this out, and be able to work with database tables without a Context.

Or at least be least restrictive, I mean a way of project/class structure that will make history the several context passings I have to do now.

As it is my application has several level of classes, chained in each other, and there are a few that connects to the database, but have no whatsoever influence on the interface, so they don't actually need the Context.

Are you creating your classes in the way that you pass each time a Context to them?
If not, how you do, how you reuse a Context in a short class?

+2  A: 

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

Call openDatabase() on SQLiteDatabase.

As it is my application has several level of classes, chained in each other

Please remember that this is a mobile phone you are developing for. Too many abstraction layers will hamper performance.

Are you creating your classes in the way that you pass each time a Context to them?

Sometimes yes, sometimes no.

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

Use inner classes.

CommonsWare