更改 android 文件存放目录 getWritablePath() 为sdCard

时间:2014-05-30 04:41:32   收藏:0   阅读:429

CCFileUtils::sharedFileUtils()->getWritablePath() 默认为 /data/data/prjName/

"Java_org_cocos2dx_lib_Cocos2dxHelper.h"  的 std::string getFileDirectoryJNI() 方法

通过 jni 调用  org.cocos2dx.lib.Cocos2dxHelper.getCocos2dxWritablePath() 获取

具体"路径str" 在org.cocos2dx.lib.Cocos2dxHelper.init() 中

edit line:70 

 Cocos2dxHelper.sFileDirectory = pContext.getFilesDir().getAbsolutePath();//设置

 

to

bubuko.com,布布扣
/**方法用于获取SDCard的状态,如果手机装有SDCard,并且可以进行读写,那么方法返回的状态等于Environment.MEDIA_MOUNTED **/
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
    Cocos2dxHelper.sFileDirectory = Environment.getExternalStorageDirectory()+"/"+applicationInfo.packageName;
}
bubuko.com,布布扣

 


"Java_org_cocos2dx_lib_Cocos2dxHelper.h" 在 cocos2dx\platform\android\jni

class "Cocos2dxHelper" 在 cocos2dx\platform\android\java\src

更改 android 文件存放目录 getWritablePath() 为sdCard,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!