Android Tutorial

(avery) #1
Android Tutorial 293

Important android.content.SharedPreferences. Editor
Methods

The following block of code retrieves the activity’s private
preferences, opens the preference editor, adds a long preference
called SomeLong, and saves the change:

import android.content.SharedPreferences;
...
SharedPreferences settingsActivity = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settingsActivity.edit();
prefEditor.putLong(“SomeLong”, java.lang.Long.MIN_VALUE);
prefEditor.commit();

Free download pdf