Android播放器装载读取数据

来源:互联网 发布:百度推广做淘宝客 编辑:程序博客网 时间:2024/04/28 23:40

public class

Properties

extends Hashtable<K, V>

 

A Properties object is a Hashtable where the keys and values must be Strings. Each property can have a default Properties list which specifies the default values to be used when a given key is not found in this Properties instance.

 


//装载,读取数据
    private void load() {
        Properties properties=new Properties();
        try {
            FileInputStream stream=this.openFileInput("music.cfg");
        } catch (FileNotFoundException e) {
            return;
               
        }catch(IOException e)
        {
            return;
        }

//保存数据

boolean save() {
        Properties properties=new Properties();
        //将数据打包成Properties
        properties.put("bmusic", String.valueOf(mbMusic));
        try {
            FileOutputStream stream=this.openFileOutput("music.cfg", Context.MODE_WORLD_WRITEABLE);//hashtable结构
            //将打包好的数据写入文件中
            properties.store(stream, "");
        }catch(FileNotFoundException e)
        {
            return  false;
        }
        catch (IOException e) {
            return false;
        }
        return true;
    }


原创粉丝点击