how to use Properties and File to Save Data
the file is saved to /data/data/yourappname/files
//new a Properties object
//show how to load value
Properties properties = new Properties();
try{
FileInputSteam stream = this.openFileInput("filepath.cfg");
properties.load(steam);
}catch (FileNotFoundException e)
{
}catch(IOException e){
}
Boolean bValue = Boolean.valueof(properties.get("bValueName").toString());
//show how to store value
Properties properties = new Properties();
properties.put("bValueName",String.valueOf(bValue));
try{
FileOutputStream steam = this.openFileOutput("filepath.cfg",Context.MODE_WORLD_WRITEABLE);
properties.store(steam,"");
}catch (FileNotFoundException e)
{
}catch(IOException e){
}
sharing files/data between two apps.
the file is saved to /data/data/yourappname/files
//new a Properties object
//show how to load value
Properties properties = new Properties();
try{
FileInputSteam stream = this.openFileInput("filepath.cfg");
properties.load(steam);
}catch (FileNotFoundException e)
{
}catch(IOException e){
}
Boolean bValue = Boolean.valueof(properties.get("bValueName").toString());
//show how to store value
Properties properties = new Properties();
properties.put("bValueName",String.valueOf(bValue));
try{
FileOutputStream steam = this.openFileOutput("filepath.cfg",Context.MODE_WORLD_WRITEABLE);
properties.store(steam,"");
}catch (FileNotFoundException e)
{
}catch(IOException e){
}
sharing files/data between two apps.
如何使用Properties和File保存数据
本文详细介绍了在Android应用中使用Properties和File类来保存和加载数据的方法,包括加载和存储数据的具体步骤以及文件路径的设置。
651

被折叠的 条评论
为什么被折叠?



