Create a class for the object you want to save (for example: ObjectYouWantToStore).
Extend android.app.Application.
public class MyApp extends android.app.Application { private ObjectYouWantToStore mObject; public ObjectYouWantToStore getObject() {; return mObject; } public void setObject(ObjectYouWantToStore obj) { mObject = obj; } }
Write the path to the Application in the manifest file.
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".MyApp">
Saving data in your activity B
MyApp app = (MyApp)getApplicationContext(); app.setObject(ObjectYouWantToStore);
Access to the same data in your activity A
MyApp app = (MyApp)getApplicationContext(); ObjectYouWantToStore obj = app.getObject();
source share