Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.SharedPreferences; import android.util.Log; public class Main { /** * Tag used on log messages. */ static final String TAG = "ODMCommonUtilities"; static String gSERVER_URL = ""; static String gNAME = ""; static String gUSERNAME = ""; static String gENC_KEY = ""; static String gREG_ID = ""; static String gVALID_SSL = ""; static String gDEBUG = ""; static String gTOKEN = ""; static String gVERSION = ""; static String gINTERVAL = "0"; static String gNETWORK_ONLY = "false"; static String gHIDE_ICON = ""; static void loadVARs(Context context) { SharedPreferences mPrefs = context.getSharedPreferences("usersettings", 0); String su = mPrefs.getString("SERVER_URL", ""); setVAR("SERVER_URL", su); setVAR("NAME", mPrefs.getString("NAME", "")); setVAR("USERNAME", mPrefs.getString("USERNAME", "")); setVAR("ENC_KEY", mPrefs.getString("ENC_KEY", "")); setVAR("REG_ID", mPrefs.getString("REG_ID", "")); setVAR("VALID_SSL", mPrefs.getString("VALID_SSL", "")); setVAR("DEBUG", mPrefs.getString("DEBUG", "")); setVAR("TOKEN", mPrefs.getString("TOKEN", "")); setVAR("VERSION", mPrefs.getString("VERSION", "true")); setVAR("INTERVAL", mPrefs.getString("INTERVAL", "0")); setVAR("NETWORK_ONLY", mPrefs.getString("NETWORK_ONLY", "false")); setVAR("HIDE_ICON", mPrefs.getString("HIDE_ICON", "false")); Logd(TAG, "Loaded variables."); } static void setVAR(String s, String v) { if (s.equals("SERVER_URL")) gSERVER_URL = v; if (s.equals("NAME")) gNAME = v; if (s.equals("USERNAME")) gUSERNAME = v; if (s.equals("ENC_KEY")) gENC_KEY = v; if (s.equals("REG_ID")) gREG_ID = v; if (s.equals("VALID_SSL")) gVALID_SSL = v; if (s.equals("DEBUG")) gDEBUG = v; if (s.equals("TOKEN")) gTOKEN = v; if (s.equals("VERSION")) gVERSION = v; if (s.equals("INTERVAL")) gINTERVAL = v; if (s.equals("NETWORK_ONLY")) gNETWORK_ONLY = v; if (s.equals("HIDE_ICON")) gHIDE_ICON = v; } static void Logd(String inTAG, String message) { if (gDEBUG.equals("true")) Log.d(inTAG, message); } }