0

the SharedPreferences is called through jni from c++ code.
When APP_OPTIM := debug, the preference is saved, but not for release.

What does APP_OPTIM := release do?

2 Answers2

0

It's easy to learn what APP_OPTIM=release does. Simply run

ndk-build -B V=1 APP_OPTIM=debug

and

ndk-build -B V=1 APP_OPTIM=release

and compare the build logs.

Regarding your first question, it is most likely that the C++ optimization does not clean up some memory, and the SharedPreferences.Editor.commit() is not called, or called on a different instance of SharedPreferences.Editor (see https://stackoverflow.com/a/9677788/192373 for example).

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
0

UPDATE: It turns out the in the jni code, the return is omitted, perhaps with APP_OPTIM := debug, the return is added and for release, the return is omitted.

int getPreference(string x)
{
    jniGetPreference(x);
}


int getPreference(string x)
{
    return jniGetPreference(x);
}