存String数
private void save(String te1) {
try {
mFileOutputStream=openFileOutput(“simid”, Context.MODE_PRIVATE);
writer =new BufferedWriter(new OutputStreamWriter(mFileOutputStream));
writer.write(te1);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(writer!=null){
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
取出来
public String load(){
FileInputStream in=null;
BufferedReader reader=null;
StringBuilder content=new StringBuilder();
try {
in=openFileInput(“simid”);
reader=new BufferedReader(new InputStreamReader(in));
String line=null;
while((line=reader.readLine())!=null){
content.append(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(reader!=null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return content.toString();
}