MainActivity
public class MainActivity extends AppCompatActivity {
private TextView textView;
private EditText editText;
private SharedPreferences sharedPreferences;
// 文件名
private String fileName = "my_file";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.tv);
editText = (EditText) findViewById(R.id.et);
// 初始化SharedPreferences
// MODE_APPEND:添加新数据时,不会覆盖旧数据,新旧数据共存
// MODE_PRIVATE:以私有形式存储数据,新数据覆盖旧数据(多数情况使用该模式)
shar