private class MyBtn1OnClickListener implements View.OnClickListener {
public void onClick(View v) {
SharedPreferences sp = getSharedPreferences("FanNengTec", Context.MODE_PRIVATE);
Editor editor = sp.edit();
editor.putString("UserName", "小张");
editor.putString("Password", "1234");
//sp.edit().putInt("age", 11);
editor.commit();
String strInfo = "已经写入数据!";
Toast.makeText(getApplicationContext(), strInfo, Toast.LENGTH_LONG).show();
}
}//MyBtn1OnClickListener
private class MyBtn2OnClickListener implements View.OnClickListener {
public void onClick(View v) {
SharedPreferences sp = getSharedPreferences("FanNengTec", Context.MODE_PRIVATE);
String name = sp.getString("UserName", null);
String pwd = sp.getString("Password", null);
//int age = sp.getInt("age", 0); }
String strInfo = "User:" + name + " Pwd:" + pwd;
Toast.makeText(getApplicationContext(), strInfo, Toast.LENGTH_LONG).show();
}
}//MyBtn2OnClickListener
public void onClick(View v) {
SharedPreferences sp = getSharedPreferences("FanNengTec", Context.MODE_PRIVATE);
Editor editor = sp.edit();
editor.putString("UserName", "小张");
editor.putString("Password", "1234");
//sp.edit().putInt("age", 11);
editor.commit();
String strInfo = "已经写入数据!";
Toast.makeText(getApplicationContext(), strInfo, Toast.LENGTH_LONG).show();
}
}//MyBtn1OnClickListener
private class MyBtn2OnClickListener implements View.OnClickListener {
public void onClick(View v) {
SharedPreferences sp = getSharedPreferences("FanNengTec", Context.MODE_PRIVATE);
String name = sp.getString("UserName", null);
String pwd = sp.getString("Password", null);
//int age = sp.getInt("age", 0); }
String strInfo = "User:" + name + " Pwd:" + pwd;
Toast.makeText(getApplicationContext(), strInfo, Toast.LENGTH_LONG).show();
}
}//MyBtn2OnClickListener