Hey there all,
I'm having a problem that i don't know how to resolve.
I have a broadcast receiver catching a call from the system. I need
this receiver to set a flag so that the next time my app runs it can
do something different.
I am trying to do this with a shared pref but it is not working.
In the receiver I do:
SharedPreferences sharedPreferences =
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
sharedPreferences.edit().putBoolean("changed", true);
sharedPreferences.edit().commit();
Then when i start my app I check like so:
sharedPreferences = getSharedPreferences(PREFS_NAME,
MODE_PRIVATE);
if (sharedPreferences.getBoolean("changed", false)){
hasChanged = true;
sharedPreferences.edit().putBoolean("changed", false);
sharedPreferences.edit().commit();
}
This does not work. If I download the file from the emulator after
the receiver has triggered it is empty. It exists but there is no key
value pair.
What am I doing wrong? Is there a better way to flag my app to run
differently on next startup?
Any help???
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en