EditPreferences.java :  » UnTagged » petdb » uk » org » aspellclark » petsdb » Android Open Source

Android Open Source » UnTagged » petdb 
petdb » uk » org » aspellclark » petsdb » EditPreferences.java
package uk.org.aspellclark.petsdb;

import uk.org.aspellclark.common.AbstractEditPreferences;
import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceManager;

/**
 * this class allows the user to edit the application preferences
 * for the petsdb application. 
 * 
 * @author andy
 *
 */
public final class EditPreferences extends AbstractEditPreferences {

  public static final String PREF_APPLICATION_DATA_DIRECTORY = "ApplicationDataDirectory";
  public static final String PREF_APPLICATION_DATA_DIRECTORY_DEF = "PetsDb";
  public static final String PREF_BACKUP_FILENAME = "backupFilename";
  public static final String PREF_BACKUP_FILENAME_DEF = "petsdb.backup.xml";

  /** Get the current value of the application data directory option */
  public static String getApplicationDataDirectory(final Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context).getString(PREF_APPLICATION_DATA_DIRECTORY,
        PREF_APPLICATION_DATA_DIRECTORY_DEF);
  }

  /**
   * returns the value for the BackupFilename preference.
   * @return
   */
  public static String getBackupFilename(final Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context).getString(PREF_BACKUP_FILENAME,
        PREF_BACKUP_FILENAME_DEF);
  }

  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.addPreferencesFromResource(R.xml.preferences);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.