android - Shared preferrence doesn't work -
I try to use shared preferences in my app to see if the question has been answered. I am using it every time I use it. It does not work, can anyone help me to change it into shared priorities?
If the question has been answered then here is the activity of the situation:
The public class extends question activity [Boolean answers; Int id; String reply; Public Intelligence (id = i; Answer = wrong; }}
And when he gives the answer, it becomes true (answer = true)
There is some work to not see here,
// Activity Item = New ArrayList & lt; Question & gt; (); } Secure zero activation use (int requestcode, integer result code, int i) {int id = i.getExtras (). GetInt ("id"); If (question.gate (id). Answer) {// do something}}}
I have tried to work in shared priorities, but it does not work. It works now, but I want to save and load it.
You can use the following code to save an activity whithin:
Shared shared references = PrefermentManager.getDefaultSharedPreferences (this); SharedPreferences.Editor Editor = sharePref.edit (); Editor.putString (getString (R.id.your_key), value); Editor.apply ();
You can use it to read the values within an activity:
Shared shared contexts = PreferenceManager.getDefaultSharedPreferences (this ); String Value = Shared PF .getString (getString (R.id.your_key), "");
Comments
Post a Comment