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 sharedPreferences = null;
    private static SharedPreferences.Editor editor = null;

    /**
     * Initialize the SharedPreferences instance for the app.
     *  This method must be called before using any other methods of this class.
     */

    public static void init(Context mcontext) {
        if (sharedPreferences == null) {
            sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mcontext);
            editor = sharedPreferences.edit();
        }
    }
}