How To Save Chronometer Time And Retrieve It In Another Activity Using Sharedpreferences
I have a chronometer in Mainactivity.java I wanted to save the starting time using SharedPreferences and get the starting time show it in another activity but I can't figure out ho
Solution 1:
if you are using the sharedpreference only in one activity it's ok to use getDefaultSharedPreferences() or getPreferences() methods on your activity.but in your case(as mentioned in the documentation) which is using one sharedPreference for multiple activities, you should assign a name to the sharedpreference.
this way the activity knows to get which of your sharedpreferences. just change this in your code
SharedPreferences pref = getSharedPreferences("chornometer", Context.MODE_PRIVATE);
for more information read the documentation
Post a Comment for "How To Save Chronometer Time And Retrieve It In Another Activity Using Sharedpreferences"