문제

if sp.clear(); and sp.commit(); is executed to clear the values of SharedPreferences.

It will only clear the values for the particular instance that was used to initialize the SharedPreferences?

It will not clear whatever values that was stored on SharedPreferences by other application?

도움이 되었습니까?

해결책 2

Use sp.remove().The remove() method will remove the shared preference.

다른 팁

Calling sp.clear(); will remove only one shared preferences file's values.

When you use a method to get access to shared preferences, you specify the file name using getSharedPreferences (String name, int mode) method. All the preferences in this file only will be removed.

If you use PreferenceManager.getDefaultSharedPreferences(context) to get access to your shared preferences, it will still remove values from only one file which is the default file for the context you specified in the parameter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top