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.content.SharedPreferences.Editor;

public class Main {
    public static final String DEF_PREF_NAME = "Default";

    public static void setLongValue(Context context, String name, long value) {
        SharedPreferences pref = getPref(context, DEF_PREF_NAME);
        Editor editor = pref.edit();
        editor.putLong(name, value);
        editor.commit();
    }

    public static SharedPreferences getPref(Context context, String name) {
        return context.getSharedPreferences(name, Context.MODE_PRIVATE);
    }
}