I am facing weird situation here.
Following routine is called after I close my preference activity.
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String tmp = preferences.getString("unit", "C");
CommonTool.temperatureUnit = tmp;
What it does is, getting the settings that I made from the preference activity and I am storing it to a global variable called CommonTool.temperatureUnit. In this case, value "C" is assigned to it.
Fine by now.
In side the CommonTool class, I have a function which returns a temperature in Celsius or Fahrenheit depends on the user preference, I got from the preference activity.
public static String getCommonTemperature(int celsius) {
int ret;
if (temperatureUnit == "C") {
ret = celsius;
}
else {
ret = (9/5) * celsius + 32;
}
return Integer.toString(ret);
}
The thing is.. it keeps fall into else
part of it while temperatureUnit contains "C".
Does anyone have any idea? Thanks in advance.