Possible Duplicate:
how to use getSharedPreferences in android
I am new Android Developer. I have a query regarding Shared Preference.
How long data will be persisted in ‘SharedPreference’ of Android App?
My requirement is to persist data for a a particular user until he log-off from the app. If same user or new user logs-in from same or new device, he/ she should have no content stored in Shared Preference from earlier session.
Please guide me to develop this. Thanks
SharedPreferenceswill persist data until you clear/overwrite the data by yourself or until the user uninstalls the app or you clear app’s cache.With respect to your question, when the user logs off from the app you can perform
SharedPreferences.Editor.clear()followed by acommit()to remove all saved data of the current user from shared preference.More info. here: SharedPreferences.Editor clear ()