We’re working on a fairly complicated set of software for Android. In order to simplify things (like common tasks), I’m in the process of moving some of the things our software does (like database access) into the Application so that the various activities can access them when necessary.
In an activity, I can use getApplication() to gain access to the Application’s data members, but I can’t figure out how to do the reverse from the Application. Is there an easy way to gain “visibility” from an Android Application into its dependent Activities?
The
Applicationclass (in general) should not be concerned with anyActivityor other components.Simply create a database helper (extend
SQLiteOpenHelperfor example) and have yourApplicationcreate and hold a static reference to it.For the
Application…Then in any app component…