Android 读写私有文件的函数
来源:互联网 发布:淘宝 直通车 编辑:程序博客网 时间:2024/06/05 02:40
public String ReadSettings(Context context)
{
FileInputStream fIn = null;
InputStreamReader isr = null;
char[] inputBuffer = new char[255];
String data = null;
try{
fIn = openFileInput("lee.txt");
isr = new InputStreamReader(fIn);
isr.read(inputBuffer);
data = new String(inputBuffer);
Toast.makeText(context, "Settings read",Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
}
finally {
try {
isr.close();
fIn.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return data;
}
public void WriteSettings(String data)
{
FileOutputStream fOut = null;
OutputStreamWriter osw = null;
try{
fOut = openFileOutput("lee.txt",MODE_PRIVATE);
osw = new OutputStreamWriter(fOut);
osw.write(data);
osw.flush();
//Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
e.printStackTrace();
//Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();
}
finally {
try {
osw.close();
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
- Android 读写私有文件的函数
- Android下私有文件夹文件的读写
- Android开发读写私有文件
- android txt文件读写(读取资源文件,读取私有和SD文件的方法)
- android私有文件的使用方法
- android私有文件资源文件的存取
- Android私有文件资源文件的存取
- Android私有文件资源文件的存取
- Android私有文件资源文件的存取
- Android私有文件资源文件的存取
- Android私有文件资源文件的存取
- android私有文件资源文件的读取
- Android文件的读写
- Android文件的读写
- Android文件的读写
- Android的文件读写
- Android文件的读写
- Android 文件的读写
- IDEN_CURRENT相关问题
- win7 IE8不能更改默认搜索
- 心情
- .net学习参考顺序
- php 显示 源文件 提示下载
- Android 读写私有文件的函数
- hibernate 使用date条件
- 针对TCP SYN洪泛攻击的防御
- 网上看房日记
- 26 附加组件【Additional Components】
- Android 开发 — 开机自启动
- 给老板汇报技术规划的一些要点
- Ant build.xml (模板)
- 微软CRM 2011 安装图文教程(转)