diff --git a/cocos2dx/platform/android/CCFileUtils_android.cpp b/cocos2dx/platform/android/CCFileUtils_android.cpp index 9a94995b89..ee11279333 100644 --- a/cocos2dx/platform/android/CCFileUtils_android.cpp +++ b/cocos2dx/platform/android/CCFileUtils_android.cpp @@ -109,7 +109,13 @@ string CCFileUtils::getWriteablePath() { // the path is: /data/data/ + package name string dir("/data/data/"); - return dir + getPackageNameJNI() + "/" ; + char* tmp = getPackageNameJNI(); + dir += tmp + "/" ; + + // release memory + delete tmp; + + return dir; } NS_CC_END; diff --git a/cocos2dx/platform/android/Cocos2dJni.cpp b/cocos2dx/platform/android/Cocos2dJni.cpp index 340defa818..122d9ec249 100644 --- a/cocos2dx/platform/android/Cocos2dJni.cpp +++ b/cocos2dx/platform/android/Cocos2dJni.cpp @@ -404,10 +404,10 @@ extern "C" return rtn; } - const char* getPackageNameJNI() + char* getPackageNameJNI() { TMethodJNI t; - const char* ret = NULL; + char* ret = NULL; if (getMethodID(t , "org/cocos2dx/lib/Cocos2dxActivity" diff --git a/cocos2dx/platform/android/Cocos2dJni.h b/cocos2dx/platform/android/Cocos2dJni.h index 004f870897..ed9f29f3c5 100644 --- a/cocos2dx/platform/android/Cocos2dJni.h +++ b/cocos2dx/platform/android/Cocos2dJni.h @@ -34,7 +34,7 @@ extern "C" void disableAccelerometerJNI(); void showMessageBoxJNI(const char * pszMsg, const char * pszTitle); void setKeyboardStateJNI(int bOpen); - const char* getPackageNameJNI(); + char* getPackageNameJNI(); } #endif // __ANDROID_COCOS2D_JNI_H__