文件操作

来源:互联网 发布:打击网络犯罪宣传资料 编辑:程序博客网 时间:2024/06/06 06:44

userDefault是一个单例,通过userDefault::getInstance();获得这个类的实例。userDefault使用哈希表结构,key-valuekey索引,value为值

userDefault->setStringForKey(“key1”,”Value”);

userDefault->setBoolForKey(“key2”true);

userDefault->setFloatForKey(“key3”,23.4);

userDefault->setDoubleForKey(“key4”,12.3);

userDefault->setIntegerForKey(“key5”,12);

userDefault->flush();//将数据写入文件

 

文件路径

//获取可以写的路径

std::string path = FileUtils::getInstance()->getWritablePath();

//拼接路径(doucunments下的路径)

std::string xmlPath = path + std::string(data.xml);

log(“%s”,xmlPath.c_str;);

 

//获取app里面的data路径

std::string path2 = FileUtils ::getInstance()->fullPathForFilename(“data.xml”);

log(“%s”,path2.c_str);

原创粉丝点击