SharedPreferences sharedPreferences = getSharedPreferences("mysharedp", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("name", "张三");
editor.putInt("age", 30);
editor.putLong("time", System.currentTimeMillis());
editor.putBoolean("default", true);
editor.commit();//记得一定要提交
Log.i("tag", "putString: " + sharedPreferences.getString("name", ""));
Log.i("tag", "putInt: " + sharedPreferences.getInt("age", 0));
Log.i("tag", "putLog: " + sharedPreferences.getLong("time", 0));
打印的结果: putLog: 1546996749035