Android Open Source - Android_Speech_To_Text_Clipboard_Widget Shared Prefs






From Project

Back to project page Android_Speech_To_Text_Clipboard_Widget.

License

The source code is released under:

GNU General Public License

If you think the Android project Android_Speech_To_Text_Clipboard_Widget 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

/*
        Copyright (C) <2014>  <Patrick Gray MacDowell>
//from  w  w w  . java 2 s. com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
package com.pgmacdesign.speechtotextclipboardwidget;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPrefs {

  
  /*
   * This allows doubles to be entered into the data field.  
   * IE) sp.putDouble(editor, "sales_dollars", 2.4231);  @Params,
   * 1) Editor being used 
   * 2) Which 'column' the data is being entered to
   * 3) Value To Enter
   */
  Editor putDouble (final Editor edit, final String key, final double value){
    return edit.putLong(key, Double.doubleToRawLongBits(value));
  }
  
  /*
   * Returns a double from the shared preferences data field. @Params,
   * IE) sp.getDouble(settings, "sales_dollars", 0.0);  @Params,
   * 1) SharedPreferences Variable (Defined in global variables)
   * 2) Which 'column' the data is being pulled from
   * 3) A Default value that will be returned if no value exists there
   */
  double getDouble(final SharedPreferences prefs, final String key, final double defaultValue){
    return Double.longBitsToDouble(prefs.getLong(key, Double.doubleToLongBits(defaultValue)));
  }
  
  /*
   * This allows Integers to be entered into the data field.  
   * IE) sp.putInt(editor, "zip_code", 90605);  @Params,
   * 1) Editor being used 
   * 2) Which 'column' the data is being entered to
   * 3) Value To Enter
   */
  Editor putInt (final Editor edit, final String key, final int value){
    return edit.putInt(key, (value));
  }
  
  /*
   * Returns an int from the shared preferences data field. @Params,
   * IE) sp.getInt(settings, "zip_code", 00000);  @Params,
   * 1) SharedPreferences Variable (Defined in global variables)
   * 2) Which 'column' the data is being pulled from
   * 3) A Default value that will be returned if no value exists there
   */
  double getInt(final SharedPreferences prefs, final String key, final int defaultValue){
    return prefs.getInt(key, (defaultValue));
  }  
  
  /*
   * This allows Strings to be entered into the data field.  
   * IE) sp.putString(editor, "work_location_home", "1401 W Imperial Hwy, La Habra, CA 90631");  @Params,
   * 1) Editor being used 
   * 2) Which 'column' the data is being entered to
   * 3) Value To Enter
   */
  Editor putString (final Editor edit, final String key, final String value){
    return edit.putString(key, value);
  }
  
  /*
   * Returns a String from the shared preferences data field. @Params,
   * IE) sp.getString(settings, "work_location_home", "Work");  @Params,
   * 1) SharedPreferences Variable (Defined in global variables)
   * 2) Which 'column' the data is being pulled from
   * 3) A Default value that will be returned if no value exists there
   */
  String getString(final SharedPreferences prefs, final String key, final String defaultValue){
    return prefs.getString(key, defaultValue);
  }
  
  
}




Java Source Code List

com.pgmacdesign.speechtotextclipboardwidget.L.java
com.pgmacdesign.speechtotextclipboardwidget.MainActivity.java
com.pgmacdesign.speechtotextclipboardwidget.MyWidget1.java
com.pgmacdesign.speechtotextclipboardwidget.SadPanda.java
com.pgmacdesign.speechtotextclipboardwidget.SharedPrefs.java
com.pgmacdesign.speechtotextclipboardwidget.SpeechToText.java
com.pgmacdesign.speechtotextclipboardwidget.Splash.java
com.pgmacdesign.speechtotextclipboardwidget.WidgetConfig.java