android.content.SharedPreferences is a package library in Android which allows a developer to store small amounts of data in key-value pairs in the device's memory. The SharedPreferences.Editor is used to modify the key-value pairs stored in the SharedPreferences.
The putInt() method in SharedPreferences.Editor is used to store integer values in the SharedPreferences. The syntax for using this method is as follows -
editor.putInt(String key, int value);
Where, key - the name of the key to be stored value - the integer value to be stored
In this example, we are creating an instance of SharedPreferences.Editor and getting the SharedPreferences instance "myPrefs" in private mode. We then use the putInt() method to store the integer value 100 with the key "highScore". Finally, we apply the changes using the apply() method.
In this example, we are storing the integer value 25 with the key "age" in the "myPrefs" SharedPreferences instance.
Package library: android.content.
Java SharedPreferences.Editor.putInt - 30 examples found. These are the top rated real world Java examples of android.content.SharedPreferences.Editor.putInt extracted from open source projects. You can rate examples to help us improve the quality of examples.