Use SharedPreferences to do remember passwords

SharedPreferences can store and read data.
SharedPreferences are stored using key-value methods.
Specific use:
SharedPreferences sp = null;
String name = "testName";
String pass = "testPass";
if(sp==null){
//The first parameter is the name of the data you save, the default creation method of MODE_PRIVATE sp = getSharedPreferences( "mNamePass" , MODE_PRIVATE );
}
//Set to start editing
SharedPreferences.Editor edit = sp.edit();
edit.putString("mName", name);
edit.putString("mPass", pass);
//submit
edit.commit();


get data
first:

sp = getSharedPreferences("mNamePass", MODE_PRIVATE);
//The first is the parameter key, the second parameter is the default value
String mName = sp.getString("mName","");
String mPass = sp.getString("mPass","");

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326765654&siteId=291194637