When I need data that is used by several actions, I just created my own application class and then used it as my "Singleton", and it works fine, since each action can then access the application’s custom context
To do this, create and extend the application class.
public class MyApplication extends Application {
Add this to your manifest so that it knows that instead of the default application
<application ... android:name=".MyApplication"
Then add any custom methods you want all your actions to have access to, and from each action use something like
((MyApplication)this.getApplicationContext()).myMethod()
You can also see Application for more details.
source share