Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get preference value android

boolean mBoolean = PreferenceManager.getDefaultSharedPreferences(yourContext).getBoolean(key, defaultValue); //getBoolean will return defaultValue is key isn't found
//you can also use getInt, getFloat, getLong, getString, getStringSet and change the variable type, of course
Comment

set preference value android

boolean committed = PreferenceManager.getDefaultSharedPreferences(yourContext).edit().putBoolean(key, mValue).commit();
//you can also use putInt, putFloat, putLong, putString, putStringSet and change the value of mValue
//committed is true if everything went alright, false if there was an error
Comment

PREVIOUS NEXT
Code Example
Java :: cannot find symbol variable log 
Java :: sum of a list using for loop in dart 
Java :: max int in java 
Java :: java responseentity 
Java :: android get distance between two locations kotlin 
Java :: array to list java 
Java :: java create file in folder 
Java :: How to efficiently find the next greater permutation of a list of values, in Java? 
Java :: spannable string in android java for color 
Java :: loop through an arraylist android studio 
Java :: java Write a program to reverse an array or string 
Java :: collatz conjecture 
Java :: insert element into arraylist java 
Java :: java nested loop 
Java :: Adding in java using user input 
Java :: converter float para string em java 
Java :: length of array in java 
Java :: primitive data types in java 
Java :: android java listview clean 
Java :: passing array by reference java 
Java :: java declare a list 
Java :: glide library in android studio 
Java :: java string to byte array utf8 
Java :: how to create localdate object in java 
Java :: como ordenar un arraylist alfabeticamente en java 
Java :: string to int in java 
Java :: String remove duplicate method in java 
Java :: Java char data type 
Java :: java indexof all occurrences 
Java :: how to update java runtime 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =