Reputation: 251
I want to using startcountdown timer method to change preference value but its not worked.
private void startCountdownTimer(final String judul){
countDownTimer = new CountDownTimer(120000, 1000) {
public void onTick(long millisUntilFinished) {
SharedPreferences pref = getActivity().getSharedPreferences("data", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putString("click"+judul, "1");
}
public void onFinish() {
SharedPreferences pref = getActivity().getSharedPreferences("data", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putString("click"+judul, "0");
}
}.start();
}
can i use method ontick and onfinish to change preference like that ?? I want to make session timeout in android actually. so Im using countdown timer to manipulate it.
Upvotes: 0
Views: 663
Reputation: 8149
Use like this is more easy
SharedPreferences pref = getActivity().getSharedPreferences("data", Context.MODE_PRIVATE);
pref.edit().putString("click"+judul, "1").commit();
Upvotes: 2