Android App开发记录 —配置文件的功能
来源:互联网 发布:2017年网络剧 编辑:程序博客网 时间:2024/05/21 06:31
1. 配置文件的功能
使用Android提供的Properties类可以很方便的实现
(1) Properties的配置
mProperty.setProperty("IP", strIP);
mProperty.setProperty("Port", strPort);
mIP.setText("");
mPort.setText("");
(2)Properties读取
public Properties loadConfig(Context context, String strPath)
{
Properties properties = new Properties();
try
{
FileInputStream s = new FileInputStream(strPath);
properties.load(s);
}
catch (Exception e)
{
properties.put("IP", "192.108.0.1");
properties.put("Port", "8086");
String strDirPath = Environment.getExternalStorageDirectory() + "/WZApp";
String strFilePath = Environment.getExternalStorageDirectory() + "/WZApp/Config.txt";
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
createDir(strDirPath);
createFile(strFilePath);
}
else if(Environment.getExternalStorageState().equals(Environment.MEDIA_REMOVED))
{
Toast.makeText(this, "没有sdCard", 1000).show();
}
e.printStackTrace();
}
return properties;
}
(2)Properties保存
public void saveConfig(Context context, String strPath, Properties properties)
{
try
{
FileOutputStream s = new FileOutputStream(strPath, false);
properties.store(s, "");
}
catch (Exception e)
{
File file = new File(strPath);
try
{
FileOutputStream s = new FileOutputStream(strPath, false);
properties.store(s, "");
}
catch(Exception ex)
{
ex.printStackTrace();
}
e.printStackTrace();
}
}
- Android App开发记录 —配置文件的功能
- Android APP开发记录
- 记录android开发用到的功能点
- Android app支付功能开发
- 【Android开发】找乐,一个笑话App的制作过程记录
- android 4.4(KitKat)上,如何开发SMS功能的APP
- Android开发全程记录(六)——完美退出APP的方法
- Android App开发记录—sd Card 读写
- Android开发记录七之文件下载的功能实现
- Android 短信轰炸机App 开发记录
- android 短信 轰炸机 app 开发 记录 (2)
- Android app 的提醒功能
- Android的App Shortcut功能
- Android的App Shortcut功能
- Android开发之APP弹幕功能
- Android开发笔记--检查更新app功能
- Android 开发中 app版本更新功能
- [From Network].NET访问配置文件app.config的功能详解
- 参加河北省自考之感悟
- iscntrl
- PC业在加速崩塌,迎来史上最坏季度
- 谈谈你对计算机硬件的发展趋势的看法。
- POJ3335(判断多边形内核是否存在)
- Android App开发记录 —配置文件的功能
- CentOS下安装php
- 复数的加法(友元函数)
- codeforce 67C - Sequence of Balls(dp)
- spring aop 同一个类中一个方法调用另一个方法,拦截不到被调用的方法
- 周鸿祎:微信已经从精神上把运营商干掉了
- NYOJ21 三个水杯
- linux学习笔记(一)—— vmwaretools实现ubuntu11.10虚拟机与win7主机文件共享
- mahout learning 代码示例