put Boolean Shared Data to SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

put Boolean 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 putBooleanShareData(String key, boolean value) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        Editor et = sp.edit();/* ww w  . j  a va2s.c  o m*/
        et.putBoolean(key, value);
        et.commit();
    }
}

Related Tutorials