android - What is the point of SharedPreferences.getFloat() -



android - What is the point of SharedPreferences.getFloat() -

the method getfloat() exists pull float value android's sharedpreferences api. yet, in xml, edittextpreference stores string value, if numeric defined.

one expect getfloat() automatically homecoming instead throws classcastexception , have utilize float.parsefloat(sharedpreferences.getstring()) value.

is there literally no utilize getfloat() or missing here?

the method getfloat() exists pull float value android's sharedpreferences api.

yes.

yet, in xml, edittextpreference stores string value, if numeric defined.

i think mixing things here. setting sharedpreferences equal elements on preferencescreen.

preferencescreen's save values sharedpreferences , it's true edittextpreferences can't save float, can save float sharedpreferences yourself:

sharedpreferences prefs = getsharedpreferences(prefs_name, 0); sharedpreferences.editor editor = prefs.edit(); editor.putfloat("afloat", 1.2f); editor.commit();

and retrieve float this:

float somefloat = prefs.getfloat("afloat", 0.0f);

android sharedpreferences android-preferences

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -