Java Code Examples for android.content.SharedPreferences.Editor

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AndroidBillingLibrary, under directory /AndroidBillingLibrary/src/net/robotmedia/billing/helper/.

Source file: AbstractBillingObserver.java

  33 
vote

public void onTransactionsRestored(){
  final SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(activity);
  final Editor editor=preferences.edit();
  editor.putBoolean(KEY_TRANSACTIONS_RESTORED,true);
  editor.commit();
}
 

Example 2

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: SetupWizard.java

  32 
vote

public void onClick(View v){
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(v.getContext());
  Editor editor=sp.edit();
  EditText username=(EditText)findViewById(R.id.usernameSetupWizard);
  EditText password=(EditText)findViewById(R.id.passwordSetupWizard);
  editor.putString("username",username.getText().toString());
  editor.putString("password",password.getText().toString());
  editor.commit();
  finish();
}
 

Example 3

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AASettings.java

  32 
vote

/** 
 * Stores the currently selected frequency when user leaves the activity
 */
@Override protected void onPause(){
  Editor edit=settings.edit();
  edit.putLong("freq",sb_freq.getProgress() + 1);
  edit.commit();
  super.onPause();
}
 

Example 4

From project AlarmApp-Android, under directory /src/com/google/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

static void setBackoff(Context context,long backoff){
  final SharedPreferences prefs=context.getSharedPreferences(PREFERENCE,Context.MODE_PRIVATE);
  Editor editor=prefs.edit();
  editor.putLong(BACKOFF,backoff);
  editor.commit();
}
 

Example 5

From project and-bible, under directory /AndBible/src/net/bible/android/control/readingplan/.

Source file: ReadingPlanControl.java

  32 
vote

/** 
 * User has chosen to start a plan
 */
public void reset(ReadingPlanInfoDto plan){
  plan.reset();
  SharedPreferences prefs=CommonUtils.getSharedPreferences();
  Editor prefsEditor=prefs.edit();
  if (plan.getCode().equals(getCurrentPlanCode())) {
    prefsEditor.remove(READING_PLAN);
  }
  prefsEditor.remove(plan.getCode() + ReadingPlanInfoDto.READING_PLAN_START_EXT);
  prefsEditor.remove(plan.getCode() + READING_PLAN_DAY_EXT);
  prefsEditor.commit();
}
 

Example 6

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: BaseActivity.java

  32 
vote

@Override public void onSuccess(){
  C2DMReceiver.performPushRegistration();
  setUserType();
  Editor editor=mSharedPrefs.edit();
  editor.putString(USER_TYPE,mUserType.name());
  editor.commit();
  onUserChanged();
  if (mLoginDialog != null) {
    mLoginDialog.dismiss();
  }
}
 

Example 7

From project android-bankdroid, under directory /src/com/liato/bankdroid/appwidget/.

Source file: AutoRefreshService.java

  32 
vote

@Override protected void onPostExecute(final Void unused){
  if ((this.errors != null) && !this.errors.isEmpty()) {
    final StringBuilder errormsg=new StringBuilder();
    errormsg.append(res.getText(R.string.accounts_were_not_updated) + ":\n");
    for (    final String err : errors) {
      errormsg.append(err);
      errormsg.append("\n");
    }
  }
  Editor edit=prefs.edit();
  edit.putLong("autoupdates_last_update",System.currentTimeMillis());
  edit.commit();
  AutoRefreshService.this.stopSelf();
}
 

Example 8

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/widget/.

Source file: WidgetProvider.java

  32 
vote

@Override public void onDeleted(android.content.Context context,int[] appWidgetIds){
  Log.d(cTag,"onDeleted");
  final int N=appWidgetIds.length;
  Editor editor=Preferences.getEditor(context);
  for (int i=0; i < N; i++) {
    String prefKey=Preferences.getWidgetQueryKey(appWidgetIds[i]);
    editor.remove(prefKey);
  }
  editor.commit();
}
 

Example 9

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/.

Source file: FacebookSessionStore.java

  32 
vote

public static boolean save(Facebook session,Context context){
  Editor editor=context.getSharedPreferences(Preferences.FACEBOOK_KEY,Context.MODE_PRIVATE).edit();
  editor.putString(Preferences.FACEBOOK_TOKEN,session.getAccessToken());
  editor.putLong(Preferences.FACEBOOK_EXPIRES,session.getAccessExpires());
  return editor.commit();
}
 

Example 10

From project android-tether, under directory /c2dm/com/google/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

static void setBackoff(Context context,long backoff){
  final SharedPreferences prefs=context.getSharedPreferences(PREFERENCE,Context.MODE_PRIVATE);
  Editor editor=prefs.edit();
  editor.putLong(BACKOFF,backoff);
  editor.commit();
}
 

Example 11

From project AndroidExamples, under directory /TumblrExample/src/com/robertszkutak/androidexamples/tumblrexample/.

Source file: TumblrExampleActivity.java

  32 
vote

private void saveBlogName(){
  String blogname1=blogname.getText().toString();
  String blogname2=pref.getString("TUMBLR_BLOG_NAME","");
  if (blogname1 != blogname2) {
    final Editor editor=pref.edit();
    editor.putString("TUMBLR_BLOG_NAME",blogname1);
    editor.commit();
  }
}
 

Example 12

From project AndroidLab, under directory /src/src/de/tubs/ibr/android/ldap/sync/.

Source file: LDAPSyncService.java

  32 
vote

private static void saveLDIFtoPreferences(String attributeUUID,SearchResultEntry user,Context c){
  SharedPreferences settings=c.getSharedPreferences("remoteState",MODE_PRIVATE);
  Editor editor=settings.edit();
  editor.putString(attributeUUID,user.toLDIFString());
  editor.commit();
}
 

Example 13

From project androidpn, under directory /androidpn-client/src/org/androidpn/client/.

Source file: XmppManager.java

  32 
vote

private void removeAccount(){
  Editor editor=sharedPrefs.edit();
  editor.remove(Constants.XMPP_USERNAME);
  editor.remove(Constants.XMPP_PASSWORD);
  editor.commit();
}
 

Example 14

From project android_5, under directory /src/aarddict/android/.

Source file: ArticleViewActivity.java

  32 
vote

@Override protected void onPause(){
  super.onPause();
  SharedPreferences prefs=getPreferences(MODE_PRIVATE);
  Editor e=prefs.edit();
  e.putFloat("articleView.scale",articleView.getScale());
  boolean success=e.commit();
  if (!success) {
    Log.w(TAG,"Failed to save article view scale pref");
  }
}
 

Example 15

From project android_7, under directory /src/org/immopoly/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

static void setBackoff(Context context,long backoff){
  final SharedPreferences prefs=context.getSharedPreferences(PREFERENCE,Context.MODE_PRIVATE);
  Editor editor=prefs.edit();
  editor.putLong(BACKOFF,backoff);
  editor.commit();
}
 

Example 16

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: WidgetOptionsActivity.java

  32 
vote

public boolean onPreferenceChange(Preference preference,Object newValue){
  if (preference == mRenderFxPref) {
    if (newValue != null) {
      int index=mRenderFxPref.findIndexOfValue(newValue.toString());
      Editor editor=mPreferences.edit();
      editor.putString("widget_render_effect",newValue.toString());
      editor.commit();
      mRenderFxPref.setSummary(mRenderFxPref.getEntries()[index]);
    }
  }
  return false;
}
 

Example 17

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: CallFeaturesSetting.java

  32 
vote

private void handleNotificationChange(Object objValue){
  boolean newValue=Boolean.parseBoolean(objValue.toString());
  Editor editor=mButtonNotifications.getEditor();
  editor.putBoolean(BUTTON_VOICEMAIL_NOTIFICATION_KEY,newValue);
  editor.commit();
  boolean visible=mPhone.getMessageWaitingIndicator() && newValue;
  NotificationMgr.getDefault().updateMwi(visible);
}
 

Example 18

From project android_packages_apps_QuickSearchBox, under directory /src/com/android/quicksearchbox/.

Source file: SearchWidgetProvider.java

  32 
vote

private static void resetVoiceSearchHintFirstSeenTime(Context context){
  SharedPreferences prefs=SearchSettings.getSearchPreferences(context);
  Editor e=prefs.edit();
  e.putLong(FIRST_VOICE_HINT_DISPLAY_TIME,System.currentTimeMillis());
  e.commit();
}
 

Example 19

From project androvoip, under directory /src/org/androvoip/.

Source file: Account.java

  32 
vote

public void save(SharedPreferences prefs){
  Editor prefsEditor=prefs.edit();
  prefsEditor.putString("protocol",mProtocol.toString());
  prefsEditor.putString("host",mHost);
  prefsEditor.putString("username",mUserName);
  prefsEditor.putString("password",mPassword);
  prefsEditor.commit();
}
 

Example 20

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: MyAccount.java

  32 
vote

private void saveUserInformation(String username,String password){
  SharedPreferences preferences=PrefSettings.getSharedPrefs(getBaseContext());
  Editor editor=preferences.edit();
  editor.putString("username",username);
  editor.putString("password",password);
  editor.commit();
}
 

Example 21

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/.

Source file: ConfigurationImpl.java

  32 
vote

public void setShowVersionNotification(boolean show){
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(mContext);
  Editor e=sp.edit();
  e.putBoolean(mContext.getString(R.string.settings_key_show_version_notification),show);
  mShowVersionNotification=show;
  e.commit();
}
 

Example 22

From project apps-for-android, under directory /Translate/src/com/beust/android/translate/.

Source file: History.java

  32 
vote

public void clear(Context context){
  int size=mHistoryRecords.size();
  mHistoryRecords=Lists.newArrayList();
  Editor edit=TranslateActivity.getPrefs(context).edit();
  for (int i=0; i < size; i++) {
    String key=HISTORY + "-" + i;
    log("Removing key " + key);
    edit.remove(key);
  }
  edit.commit();
}
 

Example 23

From project BBC-News-Reader, under directory /src/com/digitallizard/bbcnewsreader/.

Source file: ResourceService.java

  32 
vote

void updateLastLoadTime(){
  Editor editor=settings.edit();
  long time=(long)Math.floor(System.currentTimeMillis() / 1000);
  editor.putLong("lastLoadTime",time);
  editor.commit();
}
 

Example 24

From project Birthdays, under directory /src/com/rexmenpara/birthdays/util/.

Source file: Preferences.java

  32 
vote

/** 
 * CurrentVersion: the currently installed version of Astrid 
 */
public static void setCurrentVersion(int version){
  Context context=ContextManager.getContext();
  Editor editor=getPrefs(context).edit();
  editor.putInt(P_CURRENT_VERSION,version);
  editor.commit();
}
 

Example 25

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BookCatalogueApp.java

  32 
vote

/** 
 * Set a named boolean preference 
 */
public void setBoolean(String name,boolean value){
  Editor ed=this.edit();
  try {
    ed.putBoolean(name,value);
  }
  finally {
    ed.commit();
  }
}
 

Example 26

From project callmeter, under directory /src/de/ub0r/android/callmeter/ui/.

Source file: LogsFragment.java

  32 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onStop(){
  super.onStop();
  final Editor e=PreferenceManager.getDefaultSharedPreferences(this.getActivity()).edit();
  e.putBoolean(PREF_CALL,this.tbCall.isChecked());
  e.putBoolean(PREF_SMS,this.tbSMS.isChecked());
  e.putBoolean(PREF_MMS,this.tbMMS.isChecked());
  e.putBoolean(PREF_DATA,this.tbData.isChecked());
  e.putBoolean(PREF_IN,this.tbIn.isChecked());
  e.putBoolean(PREF_OUT,this.tbOut.isChecked());
  e.commit();
}
 

Example 27

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/utils/.

Source file: Utils.java

  32 
vote

public static void saveToPreferences(Context context,String key,String message){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  Editor edit=prefs.edit();
  edit.putString(key,message);
  edit.commit();
}
 

Example 28

From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/core/.

Source file: UpdateManager.java

  32 
vote

/** 
 * performCleanInstallDefaultsIfNecessary
 * @param activity
 */
public static void performCleanInstallDefaultsIfNecessary(Activity activity){
  if (null != activity) {
    SharedPreferences persistent_storage=PreferenceManager.getDefaultSharedPreferences(activity);
    String updated_tag="CLEAN_INSTALL_DEFAULTS_PERFORMED";
    if (persistent_storage.getBoolean(updated_tag,false) == false) {
      Editor persistent_storage_editor=persistent_storage.edit();
      persistent_storage_editor.putBoolean("facebook_check_in_default",true);
      persistent_storage_editor.putBoolean("foursquare_check_in_default",true);
      persistent_storage_editor.putBoolean("gowalla_check_in_default",true);
      persistent_storage_editor.putBoolean(updated_tag,true);
      persistent_storage_editor.commit();
    }
  }
}
 

Example 29

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: CHMIWidgetProvider.java

  32 
vote

@Override public void onEnabled(Context context){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  Editor editor=prefs.edit();
  editor.putString(WG_IMAGE_ETAG,"");
  editor.putString(WG_IMAGE_MD5,"");
  editor.putLong(WG_IMAGE_AGE,0L);
  editor.commit();
}
 

Example 30

From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/app/.

Source file: BookmarkManager.java

  32 
vote

private void store(){
  Editor editor=settings.edit();
  try {
    bookmarks.put(netnick,stations);
    editor.putString("bookmarks",bookmarks.toString());
    editor.commit();
  }
 catch (  JSONException e) {
    Log.i("CityBikes","Unable to store bookmarks");
    e.printStackTrace();
  }
  editor=null;
}
 

Example 31

From project cmsandroid, under directory /src/com/zia/freshdocs/preference/.

Source file: CMISPreferencesManager.java

  32 
vote

protected void storePreferences(Context ctx,Map<String,CMISHost> map){
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(ctx);
  byte[] encPrefs=Base64.encodeBase64(SerializationUtils.serialize((Serializable)map));
  Editor prefsEditor=sharedPrefs.edit();
  prefsEditor.putString(SERVERS_KEY,new String(encPrefs));
  prefsEditor.putBoolean(PREFS_SET_KEY,true);
  prefsEditor.commit();
}
 

Example 32

From project convertcsv, under directory /ConvertCSV/src/org/openintents/convertcsv/common/.

Source file: ConvertCsvBaseActivity.java

  32 
vote

/** 
 * @return
 */
public String getFilenameAndSavePreferences(){
  String fileName=mEditText.getText().toString();
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  Editor editor=prefs.edit();
  editor.putString(PREFERENCE_FILENAME,fileName);
  editor.putString(PREFERENCE_FORMAT,getFormat());
  if (mCustomEncoding.isChecked()) {
    editor.putString(PREFERENCE_ENCODING,((Encoding)mSpinnerEncoding.getSelectedItem()).name());
  }
  editor.putBoolean(PREFERENCE_USE_CUSTOM_ENCODING,mCustomEncoding.isChecked());
  editor.commit();
  return fileName;
}
 

Example 33

From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: WidgetOptionsActivity.java

  32 
vote

public boolean onPreferenceChange(Preference preference,Object newValue){
  if (preference == mRenderFxPref) {
    if (newValue != null) {
      int index=mRenderFxPref.findIndexOfValue(newValue.toString());
      Editor editor=mPreferences.edit();
      editor.putString("widget_render_effect",newValue.toString());
      editor.commit();
      mRenderFxPref.setSummary(mRenderFxPref.getEntries()[index]);
    }
  }
  return false;
}
 

Example 34

From project cw-advandroid, under directory /Push/C2DM/src/com/google/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

static void setBackoff(Context context,long backoff){
  final SharedPreferences prefs=context.getSharedPreferences(PREFERENCE,Context.MODE_PRIVATE);
  Editor editor=prefs.edit();
  editor.putLong(BACKOFF,backoff);
  editor.commit();
}
 

Example 35

From project cw-omnibus, under directory /Push/C2DM/src/com/google/android/c2dm/.

Source file: C2DMessaging.java

  32 
vote

static void setBackoff(Context context,long backoff){
  final SharedPreferences prefs=context.getSharedPreferences(PREFERENCE,Context.MODE_PRIVATE);
  Editor editor=prefs.edit();
  editor.putLong(BACKOFF,backoff);
  editor.commit();
}
 

Example 36

From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/io/json/.

Source file: JsonVersionedHandler.java

  32 
vote

private void updatePrefs(){
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mContext);
  final Editor editor=prefs.edit();
  editor.putInt(mPrefsKey,mVersion);
  editor.commit();
}
 

Example 37

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/billing/.

Source file: BillingManager.java

  32 
vote

@Override public void onTransactionsRestored(){
  final SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(context);
  final Editor editor=preferences.edit();
  editor.putBoolean(KEY_TRANSACTIONS_RESTORED,true);
  editor.commit();
  this.disableAds();
}
 

Example 38

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/.

Source file: DropboxBackupActivity.java

  32 
vote

/** 
 * Shows keeping the access keys returned from Trusted Authenticator in a local store, rather than storing user name & password, and re-authenticating each time (which is not to be done, ever).
 */
public void storeKeys(String key,String secret){
  SharedPreferences prefs=getSharedPreferences(ACCOUNT_PREFS_NAME,0);
  Editor edit=prefs.edit();
  edit.putString(ACCESS_KEY_NAME,key);
  edit.putString(ACCESS_SECRET_NAME,secret);
  edit.commit();
}
 

Example 39

From project eoit, under directory /EOIT/src/fr/eoit/parameter/.

Source file: Parameters.java

  32 
vote

public static void saveParameters(Context context){
  Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
  editor.putLong("character_id",characterId);
  editor.putLong("user_id",keyId);
  editor.putString("api_key",vCode);
  editor.putBoolean("mining_active",isMiningActive);
  editor.putInt("territory",territory);
  editor.putFloat("security_status",securityStatus);
  editor.commit();
}
 

Example 40

From project facebook-android-sdk, under directory /examples/Hackbook/src/com/facebook/android/.

Source file: SessionStore.java

  32 
vote

public static boolean save(Facebook session,Context context){
  Editor editor=context.getSharedPreferences(KEY,Context.MODE_PRIVATE).edit();
  editor.putString(TOKEN,session.getAccessToken());
  editor.putLong(EXPIRES,session.getAccessExpires());
  editor.putLong(LAST_UPDATE,session.getLastAccessUpdate());
  return editor.commit();
}
 

Example 41

From project gast-lib, under directory /app/src/root/gast/playground/pref/.

Source file: PreferenceHelper.java

  32 
vote

public void setLanguage(Context context,Locale locale){
  SharedPreferences preferences=getPrefs();
  Editor editor=preferences.edit();
  editor.putString(context.getString(R.string.pref_language),locale.toString());
  editor.commit();
}
 

Example 42

From project GCM-Demo, under directory /gcm/gcm-client/src/com/google/android/gcm/.

Source file: GCMRegistrar.java

  32 
vote

/** 
 * Sets the registration id in the persistence store.
 * @param context application's context.
 * @param regId registration id
 */
static String setRegistrationId(Context context,String regId){
  final SharedPreferences prefs=getGCMPreferences(context);
  String oldRegistrationId=prefs.getString(PROPERTY_REG_ID,"");
  int appVersion=getAppVersion(context);
  Log.v(TAG,"Saving regId on app version " + appVersion);
  Editor editor=prefs.edit();
  editor.putString(PROPERTY_REG_ID,regId);
  editor.putInt(PROPERTY_APP_VERSION,appVersion);
  editor.commit();
  return oldRegistrationId;
}
 

Example 43

From project generic-store-for-android, under directory /src/com/wareninja/opensource/genericstore/.

Source file: GenericStore.java

  32 
vote

private static boolean setCustomDataInLocal(String key,Object value,Context context){
  Editor editor=context.getSharedPreferences(PREF_FILE_NAME,Context.MODE_PRIVATE).edit();
  if (value instanceof Boolean)   editor.putBoolean(key,(Boolean)value);
 else   if (value instanceof Integer)   editor.putInt(key,(Integer)value);
 else   if (value instanceof String)   editor.putString(key,(String)value);
 else   if (value instanceof Float)   editor.putFloat(key,(Float)value);
 else   if (value instanceof Long)   editor.putLong(key,(Long)value);
  return editor.commit();
}
 

Example 44

From project gh4a, under directory /src/com/gh4a/.

Source file: BaseActivity.java

  32 
vote

public void unauthorized(){
  SharedPreferences sharedPreferences=getSharedPreferences(Constants.PREF_NAME,MODE_PRIVATE);
  if (sharedPreferences != null) {
    if (sharedPreferences.getString(Constants.User.USER_LOGIN,null) != null && sharedPreferences.getString(Constants.User.USER_AUTH_TOKEN,null) != null) {
      Editor editor=sharedPreferences.edit();
      editor.clear();
      editor.commit();
      Intent intent=new Intent().setClass(this,Github4AndroidActivity.class);
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
      finish();
    }
  }
}
 

Example 45

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: ImApp.java

  32 
vote

public static boolean setNewLocale(Context context,String localeString){
  Locale locale=new Locale(localeString);
  Configuration config=context.getResources().getConfiguration();
  config.locale=locale;
  context.getResources().updateConfiguration(config,context.getResources().getDisplayMetrics());
  Log.d(LOG_TAG,"locale = " + locale.getDisplayName());
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  Editor prefEdit=prefs.edit();
  prefEdit.putString(context.getString(R.string.pref_default_locale),localeString);
  prefEdit.commit();
  return true;
}
 

Example 46

From project Gingerbread-Keyboard, under directory /src/com/android/inputmethod/latin/.

Source file: LanguageSwitcher.java

  32 
vote

public void persist(){
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(mIme);
  Editor editor=sp.edit();
  editor.putString(LatinIME.PREF_INPUT_LANGUAGE,getInputLanguage());
  SharedPreferencesCompat.apply(editor);
}
 

Example 47

From project GnucashMobile, under directory /GnucashMobile/src/org/gnucash/android/receivers/.

Source file: TransactionAppWidgetProvider.java

  32 
vote

@Override public void onDeleted(Context context,int[] appWidgetIds){
  super.onDeleted(context,appWidgetIds);
  Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
  for (  int appWidgetId : appWidgetIds) {
    editor.remove(TransactionsListFragment.SELECTED_ACCOUNT_ID + appWidgetId);
  }
  editor.commit();
}
 

Example 48

From project GradeCalculator-Android, under directory /GradeCalculator/src/com/jetheis/android/grades/billing/.

Source file: Security.java

  32 
vote

public static void setFullVersionUnlocked(boolean fullVersionUnlocked,Context context){
  if (fullVersionUnlocked) {
    Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.putString(UNLOCK_KEY_STORAGE_KEY,createNewEncryptedUnlockKey(context));
    editor.commit();
  }
 else {
    Editor editor=PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.remove(UNLOCK_KEY_STORAGE_KEY);
    editor.commit();
  }
}
 

Example 49

From project groundhog-reader, under directory /src/main/java/com/almarsoft/GroundhogReader/.

Source file: OptionsActivity.java

  32 
vote

/** 
 * Check if the host changed to reset al groups messages
 */
protected void checkHostChanged(){
  String newHost=mPrefs.getString("host",null);
  if (oldHost != null && newHost != null) {
    if (!oldHost.equalsIgnoreCase(newHost)) {
      Editor editor=mPrefs.edit();
      editor.putBoolean("hostChanged",true);
      editor.commit();
    }
  }
}
 

Example 50

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/logger/.

Source file: GPSLoggerService.java

  32 
vote

private void crashProtectState(){
  SharedPreferences preferences=PreferenceManager.getDefaultSharedPreferences(this);
  Editor editor=preferences.edit();
  editor.putLong(SERVICESTATE_TRACKID,mTrackId);
  editor.putLong(SERVICESTATE_SEGMENTID,mSegmentId);
  editor.putInt(SERVICESTATE_PRECISION,mPrecision);
  editor.putInt(SERVICESTATE_STATE,mLoggingState);
  editor.commit();
  Log.d(TAG,"crashProtectState()");
}
 

Example 51

From project hsDroid, under directory /src/de/nware/app/hsDroid/ui/.

Source file: DirChooser.java

  32 
vote

private void prepareDirectoryList(){
  final ArrayList<File> sdDirs=new ArrayList<File>();
  if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
    File extDir=Environment.getExternalStorageDirectory();
    FileFilter dirFilter=new FileFilter(){
      @Override public boolean accept(      File pathname){
        return pathname.isDirectory();
      }
    }
;
    for (    File file : extDir.listFiles(dirFilter)) {
      if (!file.isHidden()) {
        sdDirs.add(file);
      }
    }
    Collections.sort(sdDirs);
    getListView().setAdapter(new ArrayAdapter<File>(getApplicationContext(),R.layout.dir_chooser_item,sdDirs));
    getListView().setOnItemClickListener(new OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> parent,      View view,      int pos,      long id){
        showToast(sdDirs.get(pos).getAbsolutePath());
        Editor ed=sPreferences.edit();
        ed.putString("downloadPathPref",sdDirs.get(pos).getAbsolutePath());
        ed.commit();
        finish();
      }
    }
);
  }
 else {
    showToast(getString(R.string.error_nosdcard));
  }
}
 

Example 52

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/deprecated/languageswitcher/.

Source file: InputLanguageSelection.java

  31 
vote

@Override protected void onPause(){
  super.onPause();
  String checkedLanguages="";
  PreferenceGroup parent=getPreferenceScreen();
  int count=parent.getPreferenceCount();
  for (int i=0; i < count; i++) {
    CheckBoxPreference pref=(CheckBoxPreference)parent.getPreference(i);
    if (pref.isChecked()) {
      checkedLanguages+=get5Code(mLocaleMap.get(pref)) + ",";
    }
  }
  if (checkedLanguages.length() < 1)   checkedLanguages=null;
  Editor editor=mPrefs.edit();
  editor.putString(Settings.PREF_SELECTED_LANGUAGES,checkedLanguages);
  SharedPreferencesCompat.apply(editor);
}
 

Example 53

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: LinphoneManager.java

  31 
vote

public void initializePayloads(){
  Log.i("Initializing supported payloads");
  Editor e=mPref.edit();
  boolean fastCpu=Version.isArmv7();
  e.putBoolean(getString(pref_echo_cancellation_key),fastCpu);
  e.putBoolean(getString(R.string.pref_codec_gsm_key),true);
  e.putBoolean(getString(R.string.pref_codec_pcma_key),true);
  e.putBoolean(getString(R.string.pref_codec_pcmu_key),true);
  e.putBoolean(getString(R.string.pref_codec_speex8_key),true);
  e.putBoolean(getString(pref_codec_speex16_key),fastCpu);
  e.putBoolean(getString(pref_codec_speex32_key),fastCpu);
  boolean ilbc=LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType("iLBC",8000) != null;
  e.putBoolean(getString(pref_codec_ilbc_key),ilbc);
  boolean amr=LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType("AMR",8000) != null;
  e.putBoolean(getString(pref_codec_amr_key),amr);
  if (Version.sdkStrictlyBelow(5) || !Version.hasNeon() || !Hacks.hasCamera()) {
    e.putBoolean(getString(pref_video_enable_key),false);
  }
  e.commit();
}
 

Example 54

From project androidquery, under directory /src/com/androidquery/util/.

Source file: AQUtility.java

  31 
vote

public static void apply(Editor editor){
  if (AQuery.SDK_INT >= 9) {
    AQUtility.invokeHandler(editor,"apply",false,true,null,(Object[])null);
  }
 else {
    editor.commit();
  }
}
 

Example 55

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/service/.

Source file: ResultService.java

  31 
vote

private void sendNotification(long appId,int callerUid,int allow,long currentTime,String appNotify){
  if ((appNotify == null && !mNotify) || (appNotify != null && appNotify.equals("0")) || allow == -1) {
    return;
  }
  final String notificationMessage=getString(allow == 1 ? R.string.notification_text_allow : R.string.notification_text_deny,Util.getAppName(this,callerUid,false));
  if (mNotifyType.equals("toast")) {
    ensurePrefs();
    int lastNotificationUid=mPrefs.getInt(LAST_NOTIFICATION_UID,0);
    long lastNotificationTime=mPrefs.getLong(LAST_NOTIFICATION_TIME,0);
    final int gravity=Integer.parseInt(mPrefs.getString(Preferences.TOAST_LOCATION,"0"));
    if (lastNotificationUid != callerUid || lastNotificationTime + (5 * 1000) < currentTime) {
      mHandler.post(new Runnable(){
        @Override public void run(){
          Toast toast=Toast.makeText(getApplicationContext(),notificationMessage,Toast.LENGTH_SHORT);
          if (gravity > 0) {
            toast.setGravity(gravity,0,0);
          }
          toast.show();
        }
      }
);
      Editor editor=mPrefs.edit();
      editor.putInt(LAST_NOTIFICATION_UID,callerUid);
      editor.putLong(LAST_NOTIFICATION_TIME,currentTime);
      editor.commit();
    }
  }
 else   if (mNotifyType.equals("status")) {
    NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    Intent notificationIntent=new Intent(this,HomeActivity.class);
    PendingIntent contentIntent=PendingIntent.getActivity(this,0,notificationIntent,0);
    Notification notification=new Notification(R.drawable.stat_su,notificationMessage,currentTime);
    notification.setLatestEventInfo(this,getString(R.string.app_name),notificationMessage,contentIntent);
    notification.flags|=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
    nm.notify(callerUid,notification);
  }
}
 

Example 56

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/languageswitcher/.

Source file: InputLanguageSelection.java

  31 
vote

@Override protected void onPause(){
  super.onPause();
  String checkedLanguages="";
  PreferenceGroup parent=getPreferenceScreen();
  int count=parent.getPreferenceCount();
  for (int i=0; i < count; i++) {
    CheckBoxPreference pref=(CheckBoxPreference)parent.getPreference(i);
    if (pref.isChecked()) {
      checkedLanguages+=get5Code(mLocaleMap.get(pref)) + ",";
    }
  }
  if (checkedLanguages.length() < 1)   checkedLanguages=null;
  Editor editor=mPrefs.edit();
  editor.putString(Settings.PREF_SELECTED_LANGUAGES,checkedLanguages);
  SharedPreferencesCompat.apply(editor);
}
 

Example 57

From project andstatus, under directory /src/org/andstatus/app/.

Source file: TimelineActivity.java

  31 
vote

/** 
 * Restore (First visible item) position saved for this user and for this type of timeline
 */
private void restorePosition(){
  MyAccount tu=MyAccount.getCurrentMyAccount();
  boolean loaded=false;
  long firstItemId=-3;
  try {
    int scrollPos=-1;
    firstItemId=getSavedPosition(false);
    if (firstItemId > 0) {
      scrollPos=listPosForId(firstItemId);
    }
    if (scrollPos >= 0) {
      getListView().setSelectionFromTop(scrollPos,0);
      loaded=true;
      if (MyLog.isLoggable(TAG,Log.VERBOSE)) {
        Log.v(TAG,"Restored position " + tu.getUsername() + "; "+ positionKey(false)+ "="+ firstItemId+ "; list index="+ scrollPos);
      }
    }
 else {
      if (mSearchMode) {
        scrollPos=0;
      }
 else {
        scrollPos=getListView().getCount() - 2;
      }
      if (scrollPos >= 0) {
        setSelectionAtBottom(scrollPos);
      }
    }
  }
 catch (  Exception e) {
    Editor ed=tu.getMyAccountPreferences().edit();
    ed.remove(positionKey(false));
    ed.commit();
    firstItemId=-2;
  }
  if (!loaded && MyLog.isLoggable(TAG,Log.VERBOSE)) {
    Log.v(TAG,"Didn't restore position " + tu.getUsername() + "; "+ positionKey(false)+ "="+ firstItemId);
  }
  positionRestored=true;
}
 

Example 58

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: TimelineActivity.java

  31 
vote

/** 
 * Restore (First visible item) position saved for this user and for this type of timeline
 */
private void restorePosition(){
  TwitterUser tu=TwitterUser.getTwitterUser();
  boolean loaded=false;
  long firstItemId=-3;
  try {
    int scrollPos=-1;
    firstItemId=getSavedPosition(false);
    if (firstItemId > 0) {
      scrollPos=listPosForId(firstItemId);
    }
    if (scrollPos >= 0) {
      getListView().setSelectionFromTop(scrollPos,0);
      loaded=true;
      if (Log.isLoggable(AndTweetService.APPTAG,Log.VERBOSE)) {
        Log.v(TAG,"Restored position " + tu.getUsername() + "; "+ positionKey(false)+ "="+ firstItemId+ "; list index="+ scrollPos);
      }
    }
 else {
      if (mSearchMode) {
        scrollPos=0;
      }
 else {
        scrollPos=getListView().getCount() - 2;
      }
      if (scrollPos >= 0) {
        setSelectionAtBottom(scrollPos);
      }
    }
  }
 catch (  Exception e) {
    Editor ed=tu.getSharedPreferences().edit();
    ed.remove(positionKey(false));
    ed.commit();
    firstItemId=-2;
  }
  if (!loaded && Log.isLoggable(AndTweetService.APPTAG,Log.VERBOSE)) {
    Log.v(TAG,"Didn't restore position " + tu.getUsername() + "; "+ positionKey(false)+ "="+ firstItemId);
  }
  positionRestored=true;
}
 

Example 59

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: Birthday.java

  31 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    int version=this.getPackageManager().getPackageInfo("cz.krtinec.birthday",0).versionCode;
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
    if (version != prefs.getInt(VERSION_KEY,1)) {
      Utils.setOrCancelNotificationsAlarm(this,prefs);
      Editor editor=prefs.edit();
      editor.putInt(VERSION_KEY,version);
      editor.commit();
    }
  }
 catch (  NameNotFoundException e) {
  }
}
 

Example 60

From project buzzwords, under directory /src/com/buzzwords/.

Source file: Deck.java

  31 
vote

/** 
 * Constructor
 * @param context The Context within which to work, used to create the DB
 */
public Deck(Context context){
  mContext=context;
  mDatabaseOpenHelper=new DeckOpenHelper(context);
  mCache=new LinkedList<Card>();
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(context);
  Random r=new Random();
  mSeed=sp.getInt("deck_seed",r.nextInt());
  r=new Random(mSeed);
  Editor editor=sp.edit();
  editor.putInt("deck_seed",mSeed);
  editor.commit();
  mPosition=sp.getInt("deck_position",0);
  int sizeOfDeck=mDatabaseOpenHelper.countCards();
  mOrder=new ArrayList<Integer>(sizeOfDeck);
  for (int i=0; i < sizeOfDeck; ++i) {
    mOrder.add(i);
  }
  Collections.shuffle(mOrder,r);
  mCache=mDatabaseOpenHelper.loadCache();
  mDatabaseOpenHelper.close();
}
 

Example 61

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/layout/dialogs/last/.

Source file: LastChangeDialog.java

  31 
vote

/** 
 * @see android.app.Dialog#onCreate(android.os.Bundle)
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.dialog_last);
  try {
    SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mainContext);
    Editor editor=prefs.edit();
    editor.remove(CineShowtimeCst.PREF_KEY_APP_ENGINE);
    editor.commit();
  }
 catch (  Exception e) {
  }
  Button btnClose=(Button)findViewById(R.id.lastBtnClose);
  btnClose.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View arg0){
      LastChangeDialog.this.dismiss();
    }
  }
);
  setTitle(mainContext.getResources().getString(R.string.dialogLastChangeTitle));
  TextView contentLastChange=(TextView)findViewById(R.id.lastChangetText);
  Spanned spanned=Html.fromHtml("<b>v3.0.12</b><br><br>" + " * * Fix crash for tablet when change portrait to landscape <br>" + "<br>"+ "<b>v3.0.11</b><br><br>"+ " * * Fix somes crash bug <br>"+ "<br>"+ "<b>v3.0.10</b><br><br>"+ " * * Fix somes crash bug <br>"+ "<br>"+ "<b>v3.0.9</b><br><br>"+ " * Improve fast scrolling in results <br>"+ "<br>"+ "<b>v3.0.8</b><br><br>"+ " * Fix somes crash bug (call, widgets, sort...)<br>"+ "<br>"+ "<b>v3.0.7</b><br><br>"+ " * Fix somes crash bug (call, results, ...)<br>"+ "<br>"+ "<b>v3.0.6</b><br><br>"+ " * Fix somes crash bug<br>"+ "<br>"+ "<b>v3.0.5</b><br><br>"+ " * Fix somes crash bug<br>"+ "<br>"+ "<b>v3.0.4</b><br><br>"+ " * Fix crash bug for search movies<br>"+ " * Fix widgets crash<br>"+ "<br>"+ "<b>v3.0.3</b><br><br>"+ " * Fix crash bug for donuts phones<br>"+ "<br>"+ "<b>v3.0.2</b><br><br>"+ " * Fix starting crash<br>"+ "<br>"+ "<b>v3.0.1</b><br><br>"+ " * Fix some server bug<br>"+ " * New translation for italian<br>"+ "<br>"+ "<b>v3.0.0</b><br><br>"+ " * Reset Widgets<br>"+ " * Multi Widgets support<br>"+ " * Add of Action bar<br>"+ " * Tablet screen support<br>"+ " * Improve UI<br>"+ " * Fix some crash problems<br>"+ " * Integration of Chinese langages<br>"+ "<br>"+ "<b>v2.1.1</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.1.0</b><br><br>"+ " * Add of SplashScreen<br>"+ " * Add of Google Analytics<br>"+ " * Add of menu in movie screen<br>"+ " * App2Sd support<br>"+ " * Add of GPS animation<br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.3</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.2</b><br><br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.1</b><br><br>"+ " * Fix landscape problem for search screen<br>"+ " * Fix some crash problems<br>"+ "<br>"+ "<b>v2.0.0</b><br><br>"+ " * New UI<br>"+ " * Add Themes management<br>"+ " * Add tab review in movie screen<br>"+ " * Add trailers directly in movie screen<br>"+ " * Possibility to reserve if infomation is available<br>"+ "<br>"+ "<b>v1.10.1</b><br><br>"+ " * Minor fix corresponding to crash reports<br>"+ " * Suppression of gps message when launching app<br>"+ "<br>"+ "<b>v1.10.0</b><br><br>"+ " * Fix with favorites<br>"+ " * Fix with distance<br>"+ "<br>"+ "<b>v1.9.2</b><br><br>"+ " * Fix for archos tablet<br>"+ "<br>"+ "<b>v1.9.1</b><br><br>"+ " * Minor bug correction with favorites<br>"+ " * Change of icon<br>"+ " * <b>Please update your favorites cinemas (delete, recreate) if there is an error<b><br>"+ "<br>"+ "<b>v1.9.0</b><br><br>"+ " * Support of japanese langage and italian<br>"+ " * Change of icon<br>"+ " * Change of widget : you have to reset your widget<br>"+ "<br>"+ "<b>v1.8.1</b><br><br>"+ " * Minor fix for bookmark bug"+ "<br>"+ "<b>v1.8.0</b><br><br>"+ " * Location bugs correction<br>"+ " * crash bug correction<br>"+ " * correction on server for movie descriptions<br>"+ " * integration of 'es' langage, complete rewrite of 'en' traductions.<br>"+ " * managment of widget in cupcake in multi-screen and multi resolutions<br>"+ "<br>"+ "<b>v1.7.2 and 1.7.3</b><br>"+ "<br>"+ " * Location bugs correction<br>"+ " * crash bug correction<br>"+ " * correction on server for movie times<br>"+ " * integration of pt, pt_BR, and cz langages<br>"+ "<br>"+ "<b>v1.7.1</b><br>"+ "<br>"+ " * Minor update for integrating message when no results come from server<br>"+ "<br>"+ "<b>v1.7.0</b><br>"+ "<br>"+ " * Management of Turkish langage<br>"+ " * Management of widget for multiScreen (Add of widget for cupcake)<br>"+ "<br>"+ "<b>v1.6.2 and v1.6.3</b><br>"+ "<br>"+ " * Minor update correcting widget bug<br>"+ "<br>"+ "<b>v1.6.1</b><br>"+ "<br>"+ " * Enhance UI<br>"+ " * Management of deutch langage<br>"+ "<br>"+ "<b>v1.6.0</b><br>"+ "<br>"+ " * Integration of SkyHook? framework => you can search near your wifi position, ip position<br>"+ " * Correction of bugs with bookmarks theater.<br>"+ " * Integration of projection langage.<br>"+ " * Warning ! this version will reset your bookmark theater and the widget.<br>"+ "<br>"+ "<b>v1.5.0</b><br>"+ "<br>"+ " * Management of time of adds before movies showtime in preferences<br>"+ " * Correction of bug of gps localisation invisible buttons, for android 1.1 and 1.5<br>"+ " * Support of ru langage (Thanks Stan)<br>"+ "<br>"+ "<b>v1.4.0</b><br>"+ "<br>"+ " * Add of button Bookmarks on main screen<br>"+ " * Click on widget now open directly on theater showtimes<br>"+ " * Add of possibility to have drive direction to theaters<br>"+ " * Possibility of multi-page in widget search<br>"+ " * Add search speech for name of city and name of movie (if speech available). Works for english word only (wait for google :))<br>"+ " * Increase number of day in spinner<br>"+ " * Improve of way to get movie summary<br>"+ "<br>"+ "<b>v1.3.1</b><br>"+ "<br>"+ " * Correction for motorola blur (but many other phone could be concerned) for text of buttons invisible<br>"+ "<br>"+ "<b>v1.3.0</b><br>"+ "<br>"+ " * Management of drive time to go to theater. You could have only showtime reachables.<br>"+ " * You can add a showtime into calendar application.<br>"+ " * You can localise you with network position.<br>"+ " * Correction of issues 1,2,3 and 4.<br>"+ " * Add of option in menu for management of localisation.<br>"+ "<br>"+ "<b>v1.2.0</b><br>"+ "<br>"+ " * Add of about menu (version informations)<br>"+ " * Add of help menu<br>"+ " * Correction of bug with showtimes accross days and theaters<br>"+ " * Improve UI fast<br>"+ "<br>"+ "<b>v1.1.0</b><br>"+ "<br>"+ " * Widget management<br>"+ " * Improve UI<br>"+ " * Correction of some bugs<br>"+ "<br>"+ "<b>v1.0.0</b><br>"+ "<br>"+ " * Search theaters according to position and show movie list and showtimes corresponding<br>"+ " * You can call theaters<br>"+ " * You can launch maps to localize the theaters<br>"+ " * You can search trailers of the movies<br>"+ " * You can manage theaters bookmarks<br>"+ " * For each movie, there is a description screen with several information on the movie<br>"+ " * You can use your GPS to localise you and search show time near your position<br>"+ " * You can sort your results by :<br>"+ " * Distance of the theater<br>"+ " * Name of the theater<br>"+ " * The closest showtime<br>"+ " * You can see what's on screens during the 3 next day<br>"+ " * Search showtimes by movie name<br>"+ " * You can invite your friends by sms or mail to a film event<br>"+ " * Management of langage :<br>"+ " ->en<br>"+ " ->fr<br>"+ " ->de<br>"+ " ->pt<br>");
  contentLastChange.setText(spanned);
}
 

Example 62

From project connectbot, under directory /src/sk/vx/connectbot/.

Source file: HostListActivity.java

  31 
vote

@Override protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == REQUEST_EULA) {
    if (resultCode == Activity.RESULT_OK) {
      Editor edit=prefs.edit();
      edit.putBoolean(PreferenceConstants.EULA,true);
      edit.commit();
    }
 else {
      this.finish();
    }
  }
 else   if (requestCode == REQUEST_EDIT) {
    this.updateList();
  }
}
 

Example 63

From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/.

Source file: MainActivity.java

  31 
vote

public void loadPreferences(){
  Editor prefeditor=preferences.edit();
  if (!preferences.contains("preference_version"))   prefeditor.putInt("preference_version",D.PREFERENCE_VERSION);
  if (!preferences.contains("json_hosts")) {
    hosts=new ArrayList<Host>();
    hosts.add(new Host("Bronibooru","http://bronibooru.mlponies.com","Danbooru - JSON"));
    hosts.add(new Host("Danbooru","http://danbooru.donmai.us","Danbooru - JSON"));
    prefeditor.putString("json_hosts",D.JSONArrayFromHosts(hosts).toString());
  }
  if (!preferences.contains("selected_host"))   prefeditor.putInt("selected_host",0);
  if (!preferences.contains("page_limit"))   prefeditor.putInt("page_limit",100);
  if (!preferences.contains("rating"))   prefeditor.putString("rating","s");
  if (!preferences.contains("aggressive_prefetch"))   prefeditor.putBoolean("aggressive_prefetch",false);
  prefeditor.apply();
}
 

Example 64

From project DigitbooksExamples, under directory /DigitbooksExamples/src/fr/digitbooks/android/examples/chapitre08/.

Source file: RateDigitbooksActivity.java

  31 
vote

@Override protected void onPostExecute(String result){
  if (result != null && mRateOnce) {
    if (Config.USE_APPLICATIONS_PREFERENCES) {
      SharedPreferences preferences=getSharedPreferences(Config.PREFERENCES,Context.MODE_PRIVATE);
      Editor editor=preferences.edit();
      editor.putBoolean(Config.PREFERENCE_RATE_SENT,true);
      editor.putString(Config.PREFERENCE_COMMENT,comment);
      editor.putFloat(Config.PREFERENCE_RATING,rating);
      editor.commit();
      BackupManager backupManager=new BackupManager(RateDigitbooksActivity.this);
      backupManager.dataChanged();
    }
    SharedPreferences localPreferences=getPreferences(Context.MODE_PRIVATE);
    Editor localEditor=localPreferences.edit();
    localEditor.putBoolean(PREFERENCE_RATE_SENT,true);
    localEditor.putString(PREFERENCE_COMMENT,comment);
    localEditor.putFloat(PREFERENCE_RATING,rating);
    localEditor.commit();
  }
  dismissDialog(DIALOG_PROGRESS);
  setResult(RESULT_OK);
  finish();
}
 

Example 65

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/fragment/.

Source file: ServiceListFragment.java

  31 
vote

@Override protected boolean onItemClicked(int id){
switch (id) {
case Statics.ITEM_OVERVIEW:
    mNavReference=SERVICE_REF_ROOT;
  mNavName=(String)getText(R.string.bouquet_overview);
reloadNav();
return true;
case Statics.ITEM_SET_DEFAULT:
if (mDetailReference != null) {
Editor editor=DreamDroid.getSharedPreferences().edit();
editor.putString(DreamDroid.PREFS_KEY_DEFAULT_BOUQUET_REF,mDetailReference);
editor.putString(DreamDroid.PREFS_KEY_DEFAULT_BOUQUET_NAME,mDetailName);
if (editor.commit()) {
showToast(getText(R.string.default_bouquet_set_to) + " '" + mDetailName+ "'");
}
 else {
showToast(getText(R.string.default_bouquet_not_set));
}
}
 else {
showToast(getText(R.string.default_bouquet_not_set));
}
getSherlockActivity().invalidateOptionsMenu();
return true;
case Statics.ITEM_RELOAD:
reloadNav();
reloadDetail();
return true;
default :
return super.onItemClicked(id);
}
}
 

Example 66

From project Gaggle, under directory /src/com/geeksville/location/.

Source file: GPSClient.java

  31 
vote

private void setSimByPrefs(){
  boolean cursim=simData != null;
  boolean newsim=PreferenceManager.getDefaultSharedPreferences(this).getBoolean("fake_gps_pref",false);
  if (newsim != cursim) {
    if (newsim) {
      try {
        simData=new TestGPSDriver(this);
      }
 catch (      RuntimeException ex) {
        Toast t=Toast.makeText(this,R.string.mock_location_required,Toast.LENGTH_LONG);
        t.show();
        Editor e=PreferenceManager.getDefaultSharedPreferences(this).edit();
        e.putBoolean("fake_gps_pref",false);
        e.commit();
      }
    }
 else {
      simData.close();
      simData=null;
    }
  }
}
 

Example 67

From project HapiPodcastJ, under directory /src/info/xuluan/podcast/.

Source file: AllItemActivity.java

  31 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case MENU_REFRESH:
    mServiceBinder.start_update();
  return true;
case MENU_SORT:
new AlertDialog.Builder(this).setTitle("Chose Sort Mode").setSingleChoiceItems(R.array.sort_select,(int)pref_order,new DialogInterface.OnClickListener(){
  public void onClick(  DialogInterface dialog,  int select){
    if (mCursor != null)     mCursor.close();
    pref_order=select;
    SharedPreferences prefsPrivate=getSharedPreferences(Pref.HAPI_PREFS_FILE_NAME,Context.MODE_PRIVATE);
    Editor prefsPrivateEditor=prefsPrivate.edit();
    prefsPrivateEditor.putLong("pref_order",pref_order);
    prefsPrivateEditor.commit();
    mCursor=managedQuery(ItemColumns.URI,PROJECTION,getWhere(),null,getOrder());
    mAdapter.changeCursor(mCursor);
    dialog.dismiss();
  }
}
).show();
return true;
case MENU_SELECT:
new AlertDialog.Builder(this).setTitle("Chose Select Mode").setSingleChoiceItems(R.array.select_select,(int)pref_select,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int select){
if (mCursor != null) mCursor.close();
pref_select=select;
SharedPreferences prefsPrivate=getSharedPreferences(Pref.HAPI_PREFS_FILE_NAME,Context.MODE_PRIVATE);
Editor prefsPrivateEditor=prefsPrivate.edit();
prefsPrivateEditor.putLong("pref_select",pref_select);
prefsPrivateEditor.commit();
mCursor=managedQuery(ItemColumns.URI,PROJECTION,getWhere(),null,getOrder());
mAdapter.changeCursor(mCursor);
dialog.dismiss();
}
}
).show();
return true;
}
return super.onOptionsItemSelected(item);
}
 

Example 68

From project androidannotations, under directory /AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/api/sharedpreferences/.

Source file: SharedPreferencesCompat.java

  30 
vote

private static Method findApplyMethod(){
  try {
    Class<Editor> cls=SharedPreferences.Editor.class;
    return cls.getMethod("apply");
  }
 catch (  NoSuchMethodException unused) {
  }
  return null;
}