android - getSharedPreferences not returning a value -



android - getSharedPreferences not returning a value -

i've placed preferences file 'xml/sleeppreferences.xml' tabspec, thought that preferences part of app , there other preference files other parts.

this seems work ok. create preference change, close emulator, re-run app, go preference page, , preference had set to.

but when click tab, want utilize value of preference, goes wrong.

i've looked high , low, cannot find answer.

this excerpt of code:

public static final string pref_file_name = "sleeppreferences"; : : : sharedpreferences prefs = getsharedpreferences(pref_file_name, mode_private); string test=prefs.getstring("edittextpref", "unset");

with "unset" beingness default response if doesn't find anything.

it returns "unset"

as say, i've looked over, , code i'm using seems right code. what's going on?

thanks

dave

try using getsharedpreferences of context class. this:

public string getpassword (context contexto, string key) throws exception { sharedpreferences savedsession= contexto.getsharedpreferences(key,context.mode_private); homecoming encryption.decrypt(_seed,savedsession.getstring(key, null)); }

i think should work well:

getapplicationcontext().getsharedpreferences(pref_file_name, mode_private).getstring("edittextpref", "unset");

android

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -