I need to store a time value that needs to be retrieved and edited. Can anyone know? How to use
Sharedpreferences completed
Processing methods
For Android shared preferences, you can add the following code to your activity to complete
Sharedpreferences prefs = this.getsharedpreferences ("Com.example.app", context.mode_private);
Read the preferences in the following way:
String Datetimekey = "Com.example.app.datetime";
Use a default value using new Date ()
Long L = Prefs.getlong (Datetimekey, New Date (). GetTime ());
Edit and save preferences with the following
Date dt = Getsomedate ();
Prefs.edit (). Putlong (Datetimekey, Dt.gettime ()). apply ();
The sample directory in the Android SDK contains examples of retrieval and storage sharing in the following locations
<android-sdk-home>/samples/android-<platformversion>/apidemos Directory
Original address: http://www.itmmd.com/201410/35.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.
How to use Sharedpreferences in Android storage, read and edit values