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;

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> getStringPreferences(Context context, String... prefNames) {
        SharedPreferences preferences = getDefaultPreference(context);
        Map<String, String> prefMap = new HashMap<String, String>();
        for (String name : prefNames) {
            prefMap.put(name, preferences.getString(name, ""));
        }
        return prefMap;
    }

    public static SharedPreferences getDefaultPreference(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }
}