Converts a Bundle to HashMap - Android android.os

Android examples for android.os:Bundle

Description

Converts a Bundle to HashMap

Demo Code

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import java.util.HashMap;

public class Main{

    /**//from www .  j a v a 2  s.c o  m
     * Converts a <code>Bundle</code> to <code>HashMap</code>.
     *
     * @param bundle
     * @return
     */
    public static HashMap<String, Object> bundleToHashMap(Bundle bundle) {
        HashMap<String, Object> hashMap = new HashMap<>();

        if (bundle != null) {
            for (String key : bundle.keySet()) {
                hashMap.put(key, bundle.get(key));
            }
        }

        return hashMap;
    }

}

Related Tutorials