Example usage for android.os PersistableBundle get

List of usage examples for android.os PersistableBundle get

Introduction

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

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

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  .  ja  v a2 s  .c  o m*/
    }
    return bundle;
}