What I want to share today is the method of saving the FM module, which is Fmsharedpreferences.java
Fmsharedpreferences (context context) loads the load () method in the constructor method,
Public void Load () { log.d (LogTag, "load preferences"); if (Mcontext = = null) { return; } sharedpreferences sp = Mcontext.getsharedpreferences (Shared_prefs, Context.mode_pri vate); mtunedfrequency = Sp.getint (pref_last_tuned_frequency, DEFAULT_NO_FREQUENCY); mrecordduration = Sp.getint (last_record_duration, Record_dur_index_0_val); Mafautoswitch = Sp.getboolean (Last_af_jump_value, True); Maudiooutputmode = Sp.getboolean (Audio_output_mode, true); if (Sp.getint (fmconfig_country, 0) = = regional_band_user_defined) {mbandminfreq = Sp.getint (Fmconfig_min, MBandMin FREQ); Mbandmaxfreq = Sp.getint (Fmconfig_max, mbandmaxfreq); mchanspacing = Sp.getint (Fmconfig_step, Mchanspacing); } int num_lists = Sp.getint (list_num, 1); if (mlistofplists.size () = = 0) {for (int listiter = 0; listiter < num_lists; listiter++) {String lis Tname = sp.getstring (List_name + listiter, "FM-" + (listiter+1)); int numstations = Sp.getint (Station_num + listiter, 1); if (Listiter = = 0) {createfirstpresetlist (listname); } else {createpresetlist (listname); } presetlist curlist = Mlistofplists.get (Listiter); for (int stationiter = 0; stationiter < numstations; stationiter++) {String stationname = Sp.getstrin G (Station_Name + listiter + "x" + Stationiter, default_no_name); int stationfreq = Sp.getint (station_frequency + listiter + "x" + Stationiter, Default_no_frequency); Presetstation StatiOn = Curlist.addstation (StationName, stationfreq); int stationId = Sp.getint (station_id + listiter + "x" + Stationiter, Default_ No_stationid); STATION.SETPI (STATIONID); int pty = sp.getint (station_pty + listiter + "x" + Stationiter, default_no_pty); Station.setpty (pty); int rdssupported = Sp.getint (station_rds + listiter + "x" + Stationiter, D EFAULT_NO_RDSSUP); if (rdssupported! = 0) {station.setrdssupported (true); } else {station.setrdssupported (false); }/* Load Configuration */Setcountry (Sp.getint (Fmconfig_country, Regional_band_north_america)); /* Last list the user is navigating */Mlistindex = Sp.getint (last_list_index, 0); if (Mlistindex >= num_lists) {mlistindex=0; } }
Initialize some data out of SP
Set local frequency based on system initialization region
/*load Configuration */ if (Locale.getdefault () equals (Locale.china)) { setcountry (Sp.getint (fmconfig_ Country, Regional_band_china)); } else { setcountry (Sp.getint (Fmconfig_country, Regional_band_north_america)); } /* Last list the user was navigating */
Save frequency
public void Save ()
Set the default region
public static void SetDefaults ()
Set the adjustment frequency
public static void Settunedfrequency (Intfrequency)
Get Adjustment frequency
public static int gettunedfrequency ()
Get Next frequency
public static int getnexttunefrequency (intfrequency)
Get previous frequency
public static int getprevtunefrequency (intfrequency)
/* * * * @param mfmconfiguration mfmconfiguration set */public static void Setfmconfiguration (Fmconfig mfmconfig)/** *@r Eturn the mfmconfiguration * /public static Fmconfig Getfmconfiguration () { return mfmconfiguration; }
Set the frequency range for FM playback
public static void Setradioband (int band)
Get FM frequency range limits
public static int Getradioband ()
Get interval
public static int getchspacing ()
Set up remote Data Services
public static void setrdsstd (int std)
MFMCONFIGURATION.SETRDSSTD (STD);
Get Remote Data Services
public static int getrdsstd ()
MFMCONFIGURATION.GETRDSSTD ();
Set up national regions
public static void Setcountry (Intncountrycode)
Get Country Area
public static int Getcountry ()
Set the sound output template
Setaudiooutputmode
Set whether the recording lasts
public static void Setrecordduration (Intdurationindex)
Android FM Module Learning four source parsing (iv)