Hello
I am trying to save a persistent file with settings on Android.
I use SDL_GetPrefPath which gives me “/data/data/org.libsdl.app/files/”
Here’s my code with extras removed:
struct cfg {
//data…
} config;…
//Determine config file.
char config_file[CONFIG_FILE_LEN];
char *path = SDL_GetPrefPath(“company”, “application”);
snprintf(config_file, CONFIG_FILE_LEN, “%sconfig.txt”, path);//Write file
SDL_RWFromFile(config_file, “wb”);
size_t num = SDL_RWwrite(file, (void*)&config, sizeof(Config), 1);//Read file
SDL_RWFromFile(config_file, “rb”);
size_t num = SDL_RWread(file, (void*)&config, sizeof(Config), 1);
Write returns 1, and seems successful.
On the next launch, the file seems to open (file is not NULL or 0), but read returns 0 objects.
I do not write or read anything else to this file, just dumping this one struct to it.
I have searched and searched and cannot find an answer to this. Help is much appreciated!
Thank you!