1.Context: openFileOutput()
地址: /data/data/package/file/
参数1:文件名称
参数2:Mode_PRIVATE MODE_APPEND等
FileOutputStream out = openFileOutput(“fileName”,Context.Mode_PRIVATE)
FileInputStream in = openFileInput(“fileName”);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line="";
while((line=reader.readLine()) !=null){
//todo
}
2.Context: getSharedPreferences()
地址: /data/data/package/SharedPreferences/
SharedPreferences sp = getSharedPreferences(“fileName”,MODE_PRIVATE);
//写
SharedPreferences.Editor editor = sp.edit();
editor.putString(“name”,“david”);
editor.putInt(“age”,18);
editor.apply();
//读
String name = sp.getString(“name”,"");
int age = sp.getInt(“age”,0);