use Application class
public class MyApplication extends Application {
private static MyApplication instance = null;
private String frenchValue;
private String englishValue;
private String env_lang_Value;
public String getFrenchValue() {
return frenchValue;
}
public void setFrenchValue(String frenchValue) {
UnravelApplication.frenchValue = frenchValue;
}
public String getEnglishValue() {
return englishValue;
}
public void setEnglishValue(String englishValue) {
UnravelApplication.englishValue = englishValue;
}
public String getEnv_lang_Value() {
return env_lang_Value;
}
public void setEnv_lang_Value(String env_lang_Value) {
UnravelApplication.env_lang_Value = env_lang_Value;
}
private MyApplication() {
// Exists only to defeat instantiation.
}
public static MyApplication getInstance() {
if(instance == null) {
instance = new MyApplication();
}
return instance;
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.locale.getLanguage() == Configuration.locale.ENGLISH) {
env_lang_value=englishValue
}
if (newConfig.locale.getLanguage() == Configuration.locale.FRENCH) {
env_lang_value=frenchValue
}
}
}
from any activity while receiving push static String from server
public MyActivity extends Activity{
MyApplication myApplication = MyApplication.getInstance();
//to set while getting strings from server for both english and french
myApplication.setEnglishValue(englishValue);
myApplication.setFrenchValue(frenchValue);
if(Locale.getDefault().getDisplayLanguage().equalsIgnoreCase("English"))
myApplication.setEnv_lang_value=englishValue;
if(Locale.getDefault().getDisplayLanguage().equalsIgnoreCase("French"))
myApplication.setEnv_lang_value=frenchValue;
//to get value
String currentValue=myApplication.getEnv_lang_value;
}
Don't forget to specify Application class name in your AndroidManifest.xml's tag
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="MyApplication">