My application is simply a managing database application. I have a remote mysql server set up and my android studio application uses http post request to connect to that server.
Many options:
1) Create a global class with static variables.
2) Extend the Application class and store information in it.
2) If it's just two-three parameters, you can store it in shared preferences.
you could it done in many ways like store data in sharedpreference or database or simply create a class that contains static variables.
To store and get data from shared preference use this.
public class MyPreference {
SharedPreferences myPrefs;
SharedPreferences.Editor prefEditor;
Context context;
// ------------------------------------------------------------------costructor
public MyPreference(Context context) {
this.context = context;
myPrefs = context.getSharedPreferences("myPrefs", 0);
}
// ----------------------------------------------------------------------- user login
public void setLogin() {
prefEditor = myPrefs.edit();
prefEditor.putBoolean("login", true);
prefEditor.commit();
}
public boolean isLogin() {
return myPrefs.getBoolean("login", false);
}
public void setPassword(String userPass) {
prefEditor = myPrefs.edit();
prefEditor.putString("user", userPass);
prefEditor.commit();
}
public String getPassword() {
return myPrefs.getString("user", "");
}
}