Prevent race condition on android 6 (?) at the cost of losing the gender data (we cannot display a toast at this point unfortunately).
This commit is contained in:
parent
db6f26fcd5
commit
6eb35b955e
|
@ -285,13 +285,17 @@ public class GBApplication extends Application {
|
||||||
editor.remove("mi_user_year_of_birth");
|
editor.remove("mi_user_year_of_birth");
|
||||||
}
|
}
|
||||||
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
||||||
editor.commit();
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Integer legacyGender_1 = sharedPrefs.getInt(ActivityUser.PREF_USER_GENDER, 2);
|
//migrate the integer version of gender introduced in version 1 to a string value, needed for the way Android accesses the shared preferences
|
||||||
if(legacyGender_1 != null) {
|
int legacyGender_1 = 2;
|
||||||
editor.putString(ActivityUser.PREF_USER_GENDER, Integer.toString(legacyGender_1));
|
try {
|
||||||
|
legacyGender_1 = sharedPrefs.getInt(ActivityUser.PREF_USER_GENDER, 2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Could not access legacy activity gender", e);
|
||||||
}
|
}
|
||||||
|
editor.putString(ActivityUser.PREF_USER_GENDER, Integer.toString(legacyGender_1));
|
||||||
|
//also silently migrate the version to a string value
|
||||||
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue