我正在開發一個android應用程序,用於使用消息獲取數據。密碼創建這裏是我的代碼,我如何使用sharedPreference類來存儲密碼?如何使用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;
}
}
所以,什麼你已經嘗試在SharePrefrence的代碼? – 2013-03-06 10:41:45
@akbari dipali是的,當按鈕點擊時存儲密碼..請幫助我....感謝 – Abhilash 2013-03-08 05:59:56