Check out example codes for "android save int". It will help you in understanding the concepts better.

Code Example 1

public void saveInt(int val, String key){
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mainActivity);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putInt(key, val);
    editor.apply();
}

public int getInt(String key){
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mainActivity);
    int val = prefs.getInt(key, 0);
    return val;
}

Code Example 2

getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

Learn ReactJs, React Native from akashmittal.com