Where to store Android preference keys?

Posted by pixel on Stack Overflow See other posts from Stack Overflow or by pixel
Published on 2010-05-18T12:18:48Z Indexed on 2010/05/18 12:20 UTC
Read the original article Hit count: 224

Filed under:
|
|
|

When I create preference activity I define all preferences in xml file. Every preference has a key defined in this xml. But when I access preference I write:

SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean foo_value = appPreferences.getBoolean("foo_key_defined_in_xml", false);

Is there any way to avoid acessing "foo_key_defined_in_xml" in hard-coded way? Maybe there is a possibility to access it in R style way?

© Stack Overflow or respective owner

Related posts about preferences

Related posts about android