您的位置:首页 > 移动开发

防丢App记录(2)--将序列号通过文件存储

2016-06-04 21:42 330 查看
存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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  存储 app