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 :: swapping techniques using java 
Java :: Java if...else...if Statement 
Java :: java arrow function 
Java :: string.replace in java 
Java :: java abstract class 
Java :: java listview 
Java :: java constructor 
Java :: find number of weeks between two dates in java 
Java :: connecting to h2 database from java 
Java :: java to c++ converter 
Java :: xml button color not changing 
Java :: can you use java in unity 
Java :: android studio random number between 1 and 10 
Java :: how to change my file into binary data using java 
Java :: public class extends implements java 
Java :: Add an instance variable of type Safe to the class Room. This instance variable should be initialised in the constructor of Room, and an appropriate query should be defined to get it. 
Java :: java.lang.NoClassDefFoundError: net/sf/cb2xml/def/IItem 
Sql :: sql server drop temp table if exists 
Sql :: How to select rows with no matching entry in another table? 
Sql :: oracle find all tables with column name 
Sql :: mysql_secure_installation 
Sql :: mysql force query to use index 
Sql :: mysql return 0 if null 
Sql :: mysql unix timestamp to date 
Sql :: oracle kill session by username 
Sql :: sql delete multiple ids 
Sql :: python sqlite3 create table if not exists 
Sql :: reset identity column in sql server 
Sql :: oracle start job 
Sql :: find a column in all tables postgres 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =