views:

55

answers:

4

Hi there everyone. 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!

A: 

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().

kgiannakakis
+1  A: 

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
A: 

Thanks kgiannakakis for answering.The thread/article you provided is excellent!

Pavel
+1  A: 

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

disretrospect