put Set<String> Shared Data to SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

put Set<String> Shared Data to SharedPreferences

Demo Code


//package com.java2s;

import java.util.Set;
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 putSetShareData(String key, Set<String> value) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        Editor et = sp.edit();//  w ww  .  j  ava 2s . c om
        et.putStringSet(key, value);
        et.commit();
    }
}

Related Tutorials