Android Context Get getString(Context context, String key, String defValue)

Here you can find the source of getString(Context context, String key, String defValue)

Description

get String

Declaration

public static synchronized String getString(Context context,
            String key, String defValue) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.content.SharedPreferences;

public class Main {
    private static SharedPreferences sSharedPreferences;

    public static synchronized String getString(Context context,
            String key, String defValue) {
        return getDefaultSharedPreferences(context)
                .getString(key, defValue);
    }//from www . ja v a 2 s . c o m

    /**
     * Does file IO on calling thread. Can use {@link #getDefaultSharedPrefsAsync(android.content.Context, couk.doridori.android.lib.prefs.AbsPrefsHelper.PrefsLoader)} if on UI
     *
     * @param context
     * @return
     */
    public static synchronized SharedPreferences getDefaultSharedPreferences(
            Context context) {
        if (sSharedPreferences == null)
            sSharedPreferences = context.getSharedPreferences(
                    "defaultPrefs", Context.MODE_PRIVATE);

        return sSharedPreferences;
    }
}

Related

  1. getServiceMetaData(Context context, Class serviceClass, String key)
  2. getSignatures(final Context context)
  3. getSizeName(Context context)
  4. getSmiledText(Context context, CharSequence text)
  5. getSmsId(Context context)
  6. getString(Context context, int resourceId)
  7. getStringFromResource(int resource, Context context)
  8. getStringResourceByName(String aString, Context context)
  9. getSystemDiskCacheDir(Context context)