JAVA日报
作者:互联网
从零开始的体温app开发(sharedPreferences)
if(sharedPreferences==null){
sharedPreferences=getApplicationContext().getSharedPreferences("data", Context.MODE_PRIVATE);}
editText0.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
SharedPreferences.Editor edit=sharedPreferences.edit();
edit.putString("Name",editText0.getText().toString());
edit.commit();
}
});
public void initData(){
if(sharedPreferences==null){
sharedPreferences=getApplicationContext().getSharedPreferences("data", Context.MODE_PRIVATE);}
editText0.setText(sharedPreferences.getString("name",""));
editText5.setText(sharedPreferences.getString("num",""));
editText6.setText(sharedPreferences.getString("cl",""));
}
标签:JAVA,getString,日报,edit,void,int,sharedPreferences,public 来源: https://www.cnblogs.com/mumulailai/p/14906209.html