Example usage for android.content SharedPreferences getAll

List of usage examples for android.content SharedPreferences getAll

Introduction

In this page you can find the example usage for android.content SharedPreferences getAll.

Prototype

Map<String, ?> getAll();

Source Link

Document

Retrieve all values from the preferences.

Usage

From source file:com.footprint.cordova.plugin.localnotification.LocalNotification.java

/**
 * Retrieves a list with all currently pending notifications.
 *
 * @param callbackContext/*from w w  w.  j  a v a2 s.c  o m*/
 */
public static void getScheduledIds(CallbackContext command) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    Set<String> alarmIds = alarms.keySet();
    JSONArray pendingIds = new JSONArray(alarmIds);

    command.success(pendingIds);
}

From source file:org.openmidaas.app.session.ConsentManager.java

/**
 * Returns the map of client id to a set of attribute ids
 * @param context//ww  w .j a v  a2 s.  c om
 * @return the list of all currently saved client ids that the user
 * has consented to. 
 */
public static synchronized List<String> getAllConsents(Context context) {
    if (context == null) {
        throw new IllegalArgumentException("context cannot be null");
    }
    SharedPreferences prefs = context.getSharedPreferences(CONSENT_PERSISTENCE_STORE_NAME,
            Context.MODE_PRIVATE);
    List<String> tmpList = new ArrayList<String>();
    if (prefs != null) {
        Map<String, ?> map = prefs.getAll();
        if (prefs.getAll() != null) {
            for (Map.Entry<String, ?> entry : map.entrySet()) {
                tmpList.add(entry.getKey());
            }
            return tmpList;
        }
    }
    return null;
}

From source file:bala.padio.Settings.java

public static ArrayList<ChannelModel> GetChannelList() {
    // update channel list
    String defaultLanguage = getConfig(ConfDefaultLanguage, null);
    SharedPreferences preference = MainActivity.AppContext.getSharedPreferences(defaultLanguage,
            Context.MODE_PRIVATE);
    Map<String, ?> channelList = preference.getAll();
    ArrayList<ChannelModel> list = new ArrayList<>();
    for (Map.Entry<String, ?> channel : channelList.entrySet()) {
        try {/*  www.  ja  v  a  2s  . co m*/
            ChannelModel cm = new ChannelModel(channel.getValue().toString());
            if (cm.id != null) {
                list.add(cm);
            }
        } catch (Exception ex) {
            Log.e(TAG, ex.toString());
        }
    }
    return list;
}

From source file:com.unovo.frame.utils.SharedPreferencesHelper.java

/**
 * {@link SharedPreferences}?Bean/*from   w  ww. java2  s  .c o m*/
 * SharedPreferences??NULL
 *
 * @param context Context
 * @param clx Bean'class
 * @param <T> Any Bean
 * @return ?Bean
 */
@SuppressWarnings("unchecked")
public static <T> T load(Context context, Class<T> clx) {
    SharedPreferences sp = getSharedPreferences(context, clx);
    // Get all existing key
    Set<String> existKeys = sp.getAll().keySet();
    if (existKeys.size() == 0)
        return null;
    return (T) buildTargetFromSource(clx, null, "", existKeys, sp);
}

From source file:net.wequick.small.Small.java

public static boolean isUpgrading() {
    SharedPreferences sp = getContext().getSharedPreferences(SHARED_PREFERENCES_BUNDLE_UPGRADES, 0);
    Map<String, Boolean> flags = (Map<String, Boolean>) sp.getAll();
    if (flags == null)
        return false;
    Iterator<Map.Entry<String, Boolean>> it = flags.entrySet().iterator();
    while (it.hasNext()) {
        Boolean flag = it.next().getValue();
        if (flag != null && flag)
            return true;
    }/*from  w ww .ja  v a  2s . c  om*/
    return false;
}

From source file:com.plugin.am.LocalNotification.java

/**
 * Retrieves a list with all currently pending notifications.
 *
 * @param callbackContext//from w w  w .  j  ava  2 s  . c o  m
 */
public static void getScheduledIds(CallbackContext command) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    Set<String> alarmIds = alarms.keySet();
    JSONArray scheduledIds = new JSONArray(alarmIds);

    command.success(scheduledIds);
}

From source file:vrisini.cordova.plugin.schedule.Schedule.java

/**
 * Checks wether a notification with an ID is scheduled.
 *
 * @param id/*from   w  ww  .jav a  2s .c o m*/
 *          The notification ID to be check.
 * @param callbackContext
 */
public static void isScheduled(String id, CallbackContext callbackContext) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    boolean isScheduled = alarms.containsKey(id);
    PluginResult result = new PluginResult(PluginResult.Status.OK, isScheduled);

    callbackContext.sendPluginResult(result);
}

From source file:vrisini.cordova.plugin.schedule.Schedule.java

/**
 * Retrieves a list with all currently pending notifications.
 *
 * @param callbackContext/*w w  w . ja va 2s. c om*/
 */
public static void getScheduledIds(CallbackContext callbackContext) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    Set<String> alarmIds = alarms.keySet();
    JSONArray pendingIds = new JSONArray(alarmIds);

    callbackContext.success(pendingIds);
}

From source file:com.plugin.am.LocalNotification.java

/**
 * Checks if a notification with an ID was triggered.
 *
 * @param id/*from w  ww.j a va  2  s.  c  om*/
 *          The notification ID to be check.
 * @param callbackContext
 */
public static void isTriggered(String id, CallbackContext command) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    boolean isScheduled = alarms.containsKey(id);
    boolean isTriggered = isScheduled;

    if (isScheduled) {
        JSONObject arguments = (JSONObject) alarms.get(id);
        Options options = new Options(context).parse(arguments);
        Date fireDate = new Date(options.getDate());

        isTriggered = new Date().after(fireDate);
    }

    PluginResult result = new PluginResult(PluginResult.Status.OK, isTriggered);

    command.sendPluginResult(result);
}

From source file:com.plugin.am.LocalNotification.java

/**
 * Retrieves a list with all currently triggered notifications.
 *
 * @param callbackContext/*from w w  w  . j  a va 2 s.  c  o  m*/
 */
public static void getTriggeredIds(CallbackContext command) {
    SharedPreferences settings = getSharedPreferences();
    Map<String, ?> alarms = settings.getAll();
    Set<String> alarmIds = alarms.keySet();
    JSONArray scheduledIds = new JSONArray();
    Date now = new Date();

    for (String id : alarmIds) {
        JSONObject arguments = (JSONObject) alarms.get(id);
        Options options = new Options(context).parse(arguments);
        Date fireDate = new Date(options.getDate());
        boolean isTriggered = now.after(fireDate);

        if (isTriggered == true) {
            scheduledIds.put(id);
        }
    }

    command.success(scheduledIds);
}