

However, you should never store mutable instance data inside the Application object because if you assume that your data will stay there, your application will inevitably crash at some point with a NullPointerException. It might be tempting to use the application instance in order to avoid the overhead of passing objects between activities or keeping those in persistent storage. This might be a session token, the result of an expensive computation, etc. There is always data and information that is needed in many places within your app. That's all you should need to get started with your custom application. If we do want a custom application class, we start by creating a new class which extends as follows: import public class M圜ustomApplication extends Application Īnd specify the android:name property in the the node in AndroidManifest.xml: Instead, store any mutable shared data using persistence strategies such as files, SharedPreferences or SQLite. Note that you should never store mutable shared data inside the Application object since that data might disappear or become invalid at any time.

#Firstclass client app android android#
The Application class in Android is the base class within an Android app that contains all other components such as activities and services.
