Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.List;

import android.content.Context;
import android.content.SharedPreferences;

public class Main {
    private static final String PREFS_NAME = "prefs";

    public static String getStringPref(Context context, String key) {
        String value = null;
        if (!isEmpty(key)) {
            SharedPreferences shareConfig = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
            if (null != shareConfig) {
                value = shareConfig.getString(key, null);
            }
        }
        return value;
    }

    /**
     * @param src
     * @return true if the string is empty
     */
    public static boolean isEmpty(String src) {
        if (null == src || 0 == src.length()) {
            return true;
        }
        return false;
    }

    /**
     * @param list
     * @return true if the list is empty
     */
    public static boolean isEmpty(List<?> list) {
        if (null == list || 0 == list.size()) {
            return true;
        }
        return false;
    }
}