I was wondering, what is the common method being used to save Enum
to SharedPrefereces
? Currently, I'm using gson
to convert enum to String, and then save it to SharedPrefereces
.
Gson gson = new Gson();
// country is an enum.
String json_country = gson.toJson(country);
sharedPreferences.edit().putString(COUNTRY, json_country);
I was wondering, is this a good way? Is there any better way?
question from:
https://stackoverflow.com/questions/14750743/save-enum-to-sharedpreference 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…