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

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -