Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SharedPreference not clear after reinstall
    text
    copied!<p>I have developed an application that stores a boolean to a <code>SharePreference</code> to identify whether application start at the first time after installation. The problem is when I uninstall and install it again it still remember all <code>SharedPreference</code> that I have set on previous installation, I can't check whether application start at the first time after installation. This happen on <strong>Samsung galaxy s version 2.2.1</strong>.</p> <p>I appreciate your suggestion on the way to check first start.</p> <p>I found it strange too, but I have tested it with other devices, same version and difference version, and not found this issue. I only found this issue only on one single device.</p> <p>Here is my code, please tell me if you found something wrong :</p> <pre><code> public static boolean isFirstStart(Context context) { SharedPreferences pref = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); boolean isFirstTime = pref.getBoolean(KEY_IS_FIRST_TIME, true); if (isFirstTime) { SharedPreferences.Editor editor = pref.edit(); editor.putBoolean(KEY_IS_FIRST_TIME, false); editor.putBoolean("test", false); editor.commit(); } return isFirstTime; } </code></pre> <p>This method return true only the first installation, but false for later installation. Note: I always uninstall and install to test it. I have try to clear this application data in setting the problem is still the same, but it is ok if do this pref.edit().clear().commit(); it will be cleared for this installation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload