Because of the needs of the project, want to implement a guide to use the Welcome page effect, through the online inquiry, a solution is to be implemented through the Sharedpreferences file storage method, the specific implementation is similar to the first time to obtain the data in the Sharedpreferences, If the data does not exist, it will return the default value, the specific code implementation, immediately served.
Mainactivity 's code:
public class Mainactivity extends Activity {public Boolean flag = False;public TextView textview;public String file_name= " Sharedpreferences ";//The unique identification of the stored data @overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.activity_main); TextView = (TextView) Findviewbyid (R.id.textview); init ();} public void init () {/* * * file storage in Android, the default data will be returned if data is not stored for the first time */sharedpreferences sharedpreferences = Getsharedpreferences (file_name, context.mode_private);//Gets the saved data from the file string usernamecontent = Sharedpreferences.getstring ("username", "default data"); Textview.settext (usernamecontent);/*sharedpreferences sp = Getsharedpreferences (file_name, context.mode_private); Editor editor = Sp.edit (); Editor.clear (); editor.putstring ("name", "normal data"); Editor.commit (); String name = sp.getstring ("name", "Default data"), Textview.settext (name), */}}
Believe that through this code, you will be able to have a detailed understanding of the sharedpreferences storage.
------------If there is a mistake, but also look at a lot of advice-------------
ANDROID_ file Storage