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

    public static void savePrefInt(Context context, String key, int value) {
        if (pref == null) {
            pref = PreferenceManager.getDefaultSharedPreferences(context);
            // pref = context
            // .getSharedPreferences(PREFS, Context.MODE_PRIVATE);
        }
        if (editor == null) {
            editor = pref.edit();
        }
        editor.putInt(key, value);
        editor.commit();

    }
}