I am using the following code:
SharedPreferences.Editor edit = mPrefs.edit();
edit.putString("UUID", UUID.randomUUID().toString());
edit.commit();
//edit.apply();
This works fine, but if I comment out the commit and uncomment the apply, the app force closes on my device with no error message, or exception thrown. Strangely, this runs fine in the emulator, under 2.2 and 2.3.3. It only closes on my Nexus one running 2.2.1
I have the workaround above, but am interested as to the cause of the close.
Can anyone help?
Cheers, Venatu
apply()
was added in API level 9 (a.k.a., Android 2.3). Do not attempt to use it on Android 2.2.