In an Android app, is there anything wrong with the following approach:
public class MyApp extends android.app.Application {
private static MyApp instan
In my experience this approach shouldn't be necessary. If you need the context for anything you can usually get it via a call to View.getContext() and using the Context
obtained there you can call Context.getApplicationContext() to get the Application
context. If you are trying to get the Application
context this from an Activity
you can always call Activity.getApplication() which should be able to be passed as the Context
needed for a call to SQLiteOpenHelper()
.
Overall there doesn't seem to be a problem with your approach for this situation, but when dealing with Context
just make sure you are not leaking memory anywhere as described on the official Google Android Developers blog.