Example usage for android.os PersistableBundle keySet

List of usage examples for android.os PersistableBundle keySet

Introduction

In this page you can find the example usage for android.os PersistableBundle keySet.

Prototype

public Set<String> keySet() 

Source Link

Document

Returns a Set containing the Strings used as keys in this Bundle.

Usage

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
public static Bundle persistableBundleToBundle(PersistableBundle persistableBundle) {
    Set<String> keySet = persistableBundle.keySet();
    Bundle bundle = new Bundle();
    for (String key : keySet) {
        Object value = persistableBundle.get(key);
        if (value instanceof Boolean) {
            bundle.putBoolean(key, (boolean) value);
        } else if (value instanceof Integer) {
            bundle.putInt(key, (int) value);
        } else if (value instanceof String) {
            bundle.putString(key, (String) value);
        } else if (value instanceof String[]) {
            bundle.putStringArray(key, (String[]) value);
        } else if (value instanceof PersistableBundle) {
            Bundle innerBundle = persistableBundleToBundle((PersistableBundle) value);
            bundle.putBundle(key, innerBundle);
        }/* w  w  w.  j av  a  2s  .c  o  m*/
    }
    return bundle;
}