android - getSharedPreferences using R.something? -
with these lines:
string app_name = "@string/app_name"; sharedpreferences sharedpreferences = getsharedpreferences(app_name, 0);
i illegalargumentexception
:
file @string/app_name.xml contains path separator
if this:
sharedpreferences sharedpreferences = getsharedpreferences("myappname", 0);
it works fine how use without hard-coding app name? can't use r.string.app_name because int.
you can this
string app_name = getresources().getstring(r.string.app_name); sharedpreferences sharedpreferences = getsharedpreferences(app_name, 0);
Comments
Post a Comment