Here I'm creating a SharedPreferences if I'm not wrong i'm using this code :
SharedPreferences sp = getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putLong("ExactTime", minutesToMilliseconds(NumberPicker2.getValue()));
editor.commit();
What I'm doing is I get a value from a NumberPicker and I want to save this value and once an user restart the APP or even reboot the device (I don't know if SharedPreferences does it...) when the user opens the APP it still the same number picked from NumberPicker.
And I want to use this in a class that extends a Service. What I've tried is :
SharedPreferences sp = this.getSharedPreferences("ExactTime", Context.MODE_PRIVATE);
WifiTimeSearch = sp.getLong("ExactTime", 0);
Here is where I'm lost... I've read that this "0" means a default value but I want to use the same value that I've stored on SharedPreferences... And when I try to use this Long value, the value is "0".
What I'm doing wrong?
Aucun commentaire:
Enregistrer un commentaire