我正在开发一个用于使用消息获取数据的 android 应用程序。这里是我的密码创建代码,我如何使用 sharedPreference 类存储密码?
public class MainActivity extends Activity {
Button Switchon;
EditText passwd; //button name
String ms;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
passwd = (EditText) findViewById(R.id.passwd);
Switchon = (Button) findViewById(R.id.Switchon);
Switchon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
@SuppressWarnings("unused")
String ms = passwd.getText().toString();
Toast.makeText(getApplicationContext(), "You have successfully created and this app is on", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}