I am working on SQLiteOpenHelper , from which I will read databases using static methods (since the databases are still partitioned anyway). Is it possible to get the application context something like this:
public static final Context context = XXX;
Should it be possible right? Since I obviously only call from the current application, and both resources and databases are used inside the application.
To be clear: I want to access resources and SQLiteDatabases (if I'm wrong in the context of the contextual approach).
Is it possible to achieve?
Edit: Is it possible to get a context from inside something like this (without passing it as a parameter).
public class foo{ foo(){ XXX.getResources(); } }
Edit2: @Britzl's attempt: first idea
public class SpendoBase extends Application{ private static Context context; public SpendoBase(){ System.out.println("SPENDOBASE: " + this); System.out.println("SPENDOBASE: " + this.getBaseContext()); } public static Context getContext(){ return this.context; } }
How do I understand the context? Either in the constructor or in the form of getContext();
Ps the getBaseContext() returns null, and getApplicationContext a nullPointerException .
android android-context resources
SverkerSbrg Apr 29 '13 at 11:02 2013-04-29 11:02
source share