Merge pull request #2344 from minggo/userdefault-hotfix

fixed #2034:use previous path to get UserDefault.xml
This commit is contained in:
minggo 2013-04-09 21:00:34 -07:00
commit 6bbf4517b7
2 changed files with 9 additions and 2 deletions

View File

@ -451,7 +451,13 @@ void CCUserDefault::initXMLFilePath()
#ifdef KEEP_COMPATABILITY
if (! m_sbIsFilePathInitialized)
{
m_sFilePath += CCFileUtils::sharedFileUtils()->getWritablePath() + XML_FILE_NAME;
// xml file is stored in cache directory before 2.1.2
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
m_sFilePath = [documentsDirectory UTF8String];
m_sFilePath.append("/");
m_sFilePath += XML_FILE_NAME;
m_sbIsFilePathInitialized = true;
}
#endif

View File

@ -412,7 +412,8 @@ void CCUserDefault::initXMLFilePath()
#ifdef KEEP_COMPATABILITY
if (! m_sbIsFilePathInitialized)
{
m_sFilePath += CCFileUtils::sharedFileUtils()->getWritablePath() + XML_FILE_NAME;
// UserDefault.xml is stored in /data/data/<package-path>/ before v2.1.2
m_sFilePath += "/data/data/" + getPackageNameJNI() + "/" + XML_FILE_NAME;
m_sbIsFilePathInitialized = true;
}
#endif