Android Open Source - LearnMusicNotes Preferences






From Project

Back to project page LearnMusicNotes.

License

The source code is released under:

GNU General Public License

If you think the Android project LearnMusicNotes 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 net.fercanet.LNM;
//  ww  w  . j  a va  2s  .  c  o m
import android.content.*;


public class Preferences {
  
  public static final String PREFS_NAME = "LMN_preferences";
  public long scoresnum;   // scores showed in hall of fame
  public int scoresnumpos;  // scores num position in spinner 
  public String notationstyle;   // Notation style (classic / letters)
  public boolean informer;  // informer in training mode 
  private Context ctx;
  
  // Constructor
  public Preferences (Context context){
    ctx = context;
    ctx = ctx.getApplicationContext();
    LoadPreferences();
  }
  
  public void LoadPreferences() {
      SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);
      scoresnum = settings.getLong("hofentries", 1);                     // Getting number of top scores to store  
      scoresnumpos = settings.getInt("hofentriespos", 1);                     // Getting number of top scores to store  
      notationstyle = settings.getString("notationstyle", "seeuropean");    // Getting notation style
      informer = settings.getBoolean("informer", true);
  }
  
  public void SavePreferences() {
    SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putLong("hofentries", scoresnum);
      editor.putInt("hofentriespos", scoresnumpos);
      editor.putString("notationstyle", notationstyle);
      editor.putBoolean("informer", informer);
      editor.commit();
  }
  
}




Java Source Code List

net.fercanet.LNM.CustomSpinner.java
net.fercanet.LNM.Game.java
net.fercanet.LNM.Hof.java
net.fercanet.LNM.MainMenu.java
net.fercanet.LNM.Player.java
net.fercanet.LNM.Preferences.java
net.fercanet.LNM.Settings.java
net.fercanet.LNM.Utils.java