'Clear cache' makes delete my saved game data on Android

Hello,

My game saves some game data like code below:

void XXX::createIndexFile() {
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
std::string writablePath = sharedFileUtils->getWriteablePath();
std::string fileName = writablePath*“revealedIndex.dat”;
char dataChar[255];
FILE* fp = fopen, “w”);
for ; iter != _revealIndexArray.end; iter*+) {
int i = (int)*iter;
sprintf(dataChar, “%d\n”, i);
fwrite(dataChar, sizeof(char), strlen(dataChar), fp);
}
fclose(fp);
}

It works fine when I play this game. But this can be deleted or cleared by users using ‘Clear cache’ on App Info option of device.
Is there any way to block ‘Clear cache’ or to save file other ways?

Please give some hints or help to solve this issue~

Thanks,

Why you don’t use ccuserdefault ?

Vu Minh Tuan wrote:

Why you don’t use ccuserdefault ?

Actually, I know if I use CCCuserDefault, then I will have any problems. But, I also want to know the other way that I did.

Anyone?

HeeDong Kim wrote:

Vu Minh Tuan wrote:
> Why you don’t use ccuserdefault ?
>
>
Actually, I know if I use CCCuserDefault, then I will have any problems. But, I also want to know the other way that I did.
And my data format has arrays so look this link below:
http://www.cocos2d-x.org/boards/6/topics/10913
So I have to use CCFileUtils::getWritablePath() anyway…

Anyone?

I just found out my game has the same problem. Did you find a solution for this?

Nevermind; found the problem.

My app uses getCacheDir().getAbsolutePath(); instead of getFilesDir().getAbsolutePath(); to determine the writable path (I do not use the latest 2.1.3 release but an earlier release and added the Android 4.2 modifications by hand).

Pink Nibor wrote:

I just found out my game has the same problem. Did you find a solution for this?