I have an activity which has count buttons plus and minus such that it increments or decrements the value in editText, a non negative no. such that int value is set to colour by setTextColor property.The value persists through Shared Preference.My question is how to persist that ‘coloured’ green or red value in the editText when again entering in the app?
Share
Let’s assume your EditText is named
mEditText. First set up a SharedPreferences object:Save the color (possibly in onDestroy() or whenever the color is changed):
Read the saved value with a black default value if there is no saved data (possibly in onCreate()):