Converts a Bundle to HashMap. - Android Android OS

Android examples for Android OS:Bundle Map

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   w  w  w.j a v a  2s.  c om
     * 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