package com.sky; import android.app.Activity; import android.os.Bundle; import android.content.SharedPreferences; import android.widget.EditText; public class saveData extends Activity { public static final String SETTING_INFOS = "SETTING_Infos"; public static final String NAME = "NAME"; public static final String PASSWORD = "PASSWORD"; private EditText field_name; private EditText filed_pass; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); field_name = (EditText) findViewById(R.id.EditText01); filed_pass = (EditText) findViewById(R.id.EditText02); SharedPreferences settings = getSharedPreferences(SETTING_INFOS, 0); String name = settings.getString(NAME, ""); String password = settings.getString(PASSWORD, ""); field_name.setText(name); filed_pass.setText(password); setTitle(name+password); } @Override protected void onStop() { super.onStop(); SharedPreferences settings = getSharedPreferences(SETTING_INFOS, 0); settings.edit() .putString(NAME, field_name.getText().toString()) .putString(PASSWORD, filed_pass.getText().toString()) .commit(); } }
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。