put Int Shared Data to SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

put Int Shared Data to SharedPreferences

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Main {
    public static final String KEY = "org.activityhelp_key";
    private static Context mContext;

    public static void putIntShareData(String key, int value) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        Editor et = sp.edit();/*from www  .  jav  a 2  s.c  om*/
        et.putInt(key, value);
        et.commit();
    }
}

Related Tutorials