Android 配置文件读写

SharedPreferences preferences = getSharedPreferences("android", Context.MODE_PRIVATE);//"android"为xml文件名
String sGuardTel = preferences.getString("GuardTel", "").toString();//"GuardTel"为字符串字段名
boolean bOpen = preferences.getBoolean("GuardOpen", false);//"GuardOpen"为BOOL字段名
SharedPreferences preferences = getSharedPreferences("android", Context.MODE_PRIVATE);
Editor editor = preferences.edit();
editor.putString("GuardTel", sGuardTel);
editor.putBoolean("GuardOpen", true);

 

上一篇:VSCode+Prettier+Eslint团队代码风格统一,保存自动根据Eslint格式化


下一篇:Android Studio去掉编辑框中间的一条线