I'm kinda noob to android so please bear with me. I'm currently developing app which uses tabs. My question now is: how to store values of variables so I can access them on the other tabs? I want to create something similar to sessions in PHP where I can save variables on one page and access on the other. Please can someone help me with this? There has to be an easy way to solve this. Thanks in advance!
Asked
Active
Viewed 1,941 times
3 Answers
1
There are several ways for doing this. The choise depends on the type of the data which you need to pass between Activities.
Here there is an overview about the different approachs.

Francesco Laurita
- 23,434
- 8
- 55
- 63
-
1The link no longer works. It redirects to http://developer.android.com/training/index.html – dennisdeems Jul 31 '15 at 20:28
1
Might be worth having a look at SharedPreferences:
How to use guide http://developer.android.com/guide/topics/data/data-storage.html#pref
Class ref http://developer.android.com/reference/android/content/SharedPreferences.html

m6tt
- 4,223
- 1
- 22
- 20
0
One solution would be to use static variables to implement the "Singleton" pattern. This question presents a much better alternative for Android, which involves extending Application class and then accessing it using Context.getApplicationContext().

Community
- 1
- 1

kgiannakakis
- 103,016
- 27
- 158
- 194