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 android.content.Context;
import android.content.SharedPreferences;

public class Main {
    /**
     * The key for SharedPreferences (private mode, internal system storage)
     */
    public static final String SHARED_PREFERENCES = "SEED_SHARED_PREFERENCES";

    /**
     * Get a String from the private {@link SharedPreferences} of the app
     *
     * @param context The current context of the app
     * @param key     The key we want to request
     * @return The string retrieved from the given key
     */
    public static String getStringForKey(Context context, String key) {
        if (context == null) {
            return null;
        }
        SharedPreferences sharedPref = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
        return sharedPref.getString(key, null);
    }
}