How to assign initial value to a String in Android -


i don´t know have setup initial value of variable:

mysharedpreferences.putstringvalue("hello", "400"); 

and don´t reset if changed every time open app.

thank you!!

the best way "set" default value on method instead of set on first start of app.

mysharedpreferences.getstring("hello", "400"); 

on way android checks if there value set. if not, fallback default "400".

take @ documentation: https://developer.android.com/reference/android/content/sharedpreferences.html#getstring(java.lang.string, java.lang.string)


Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -