get Set<String> Shared Data from SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

get Set<String> Shared Data from SharedPreferences

Demo Code


//package com.java2s;
import java.util.HashSet;
import java.util.Set;
import android.content.Context;
import android.content.SharedPreferences;

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

    public static Set<String> getSetShareData(String key) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        return sp.getStringSet(key, new HashSet<String>());
    }//from  ww w  .j a  va  2 s .  c o m
}

Related Tutorials