Convert Bundle To Map<String, String> Collection - Android android.os

Android examples for android.os:Bundle

Description

Convert Bundle To Map<String, String> Collection

Demo Code

import android.os.Bundle;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Main{

    public static Map<String, String> bundleToMap(Bundle extras) {
        Map<String, String> map = new HashMap<String, String>();

        Set<String> ks = extras.keySet();
        Iterator<String> iterator = ks.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            map.put(key, extras.getString(key));
        }//w  w  w.  j a  v  a  2s. co m
        return map;
    }

}

Related Tutorials