Reputation: 12823
Of course it's not 1-for-1 code correct, but the gist of my question can be gleaned from this. Why is the result of my if statement always true? I'm guessing it has something to do with the file encoding of the preferences file? I've tried adding .toString() to the end of both. I have dumped a Toast out to see that "2.4" and "2.4" is what is returned.
if (appPrefs.getAppVer() != getAppVerName()) {
//TODO display Changes Pop-up
}
public String getAppVer() {
return appSharedPrefs.getString("appVer", "");
}
public String getAppVerName() {
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
}
Upvotes: 2
Views: 121
Reputation: 53496
Because you need to use .equals
and not !=
for string compares.
Upvotes: 3