Well, that's not a bad idea. You can use such type of a class in Android. But a small correction here. Instead of maintaining a class that holds static Data, you can make that class to extend Application class and use it store the data.
Here is a example,
public class HelloApplication extends Application {
private int globalVariable=1;
public int getGlobalVariable() {
return globalVariable;
}
public void setGlobalVariable(int globalVariable) {
this.globalVariable = globalVariable;
}
@Override
public void onCreate() {
//reinitialize variable
}
}
And in your Activity, do this,
(HelloApplication)getApplication()).setGlobalVariable(10);
int valiable=((HelloApplication)getApplication()).getGlobalVariable();
Taken from here..
And speak about SharedPreference, you should consider using them only when the value has to be stored for a long time. if not, you should make use of the Application class and use setters and getters which is the legitimate way to do this.