Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    private static SharedPreferences pref = null;

    public static String loadPrefString(Context context, String key) {
        return loadPrefString(context, key, null);
    }

    public static String loadPrefString(Context context, String key, String defaultValue) {
        if (pref == null) {
            // pref = context
            // .getSharedPreferences(PREFS, Context.MODE_PRIVATE);
            pref = PreferenceManager.getDefaultSharedPreferences(context);
        }

        return pref.getString(key, defaultValue);
    }
}