Android Open Source - kure-music-player Settings






From Project

Back to project page kure-music-player.

License

The source code is released under:

GNU General Public License

If you think the Android project kure-music-player listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kure.musicplayer;
/* ww  w .j  a va  2  s  .  c  om*/
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Interface to the application's settings.
 *
 * Keep in mind that when we call `get()` we must supply a
 * key that exists on `res/xml/preferences.xml`!
 * 
 * As a matter of fact, go look there now. 
 * 
 * Thanks a lot again, you great sources:
 * - http://stackoverflow.com/a/3624358
 * - http://android-elements.blogspot.com.br/2011/06/creating-android-preferences-screen.html
 * 
 */
public class Settings {

  /**
   * Current app's preferences.
   * They're read and saved on `res/xml/preferences.xml`.
   */
  private SharedPreferences preferences = null;
  
  /**
   * Initializes the internal settings
   */
  public void load(Context c) {
        preferences = PreferenceManager.getDefaultSharedPreferences(c);
  }
  
  /**
   * Resets all settings to default.
   */
  public void reset() {
    preferences.edit().clear().commit();
  }
  
  // QUERY METHODS
  
  public boolean get(String key, boolean defaultValue) {
    if (preferences == null)
      return defaultValue;
    
    return preferences.getBoolean(key, defaultValue);
  }
  
  public String get(String key, String defaultValue) {
    if (preferences == null)
      return defaultValue;
    
    return preferences.getString(key, defaultValue);
  }
  
  public int get(String key, int defaultValue) {
    if (preferences == null)
      return defaultValue;
    
    return preferences.getInt(key, defaultValue);
  }
}




Java Source Code List

com.kure.musicplayer.MusicController.java
com.kure.musicplayer.NotificationMusic.java
com.kure.musicplayer.NotificationSimple.java
com.kure.musicplayer.Settings.java
com.kure.musicplayer.activities.ActivityListAlbums.java
com.kure.musicplayer.activities.ActivityListSongs.java
com.kure.musicplayer.activities.ActivityMaster.java
com.kure.musicplayer.activities.ActivityMenuAlbum.java
com.kure.musicplayer.activities.ActivityMenuArtist.java
com.kure.musicplayer.activities.ActivityMenuGenre.java
com.kure.musicplayer.activities.ActivityMenuMain.java
com.kure.musicplayer.activities.ActivityMenuMusic.java
com.kure.musicplayer.activities.ActivityMenuPlaylist.java
com.kure.musicplayer.activities.ActivityMenuSettings.java
com.kure.musicplayer.activities.ActivityMenuYear.java
com.kure.musicplayer.activities.ActivityNowPlaying.java
com.kure.musicplayer.activities.ActivityQuit.java
com.kure.musicplayer.activities.XXX.java
com.kure.musicplayer.adapters.AdapterSong.java
com.kure.musicplayer.external.RemoteControlClientCompat.java
com.kure.musicplayer.external.RemoteControlHelper.java
com.kure.musicplayer.helpers.SingleToast.java
com.kure.musicplayer.model.Playlist.java
com.kure.musicplayer.model.SongList.java
com.kure.musicplayer.model.Song.java
com.kure.musicplayer.services.ServicePlayMusic.java
com.kure.musicplayer.services.ServiceScrobbleMusic.java
com.kure.musicplayer.kMP.java