get String By Case Insensitive key inside Bundle - Android android.os

Android examples for android.os:Bundle

Description

get String By Case Insensitive key inside Bundle

Demo Code

import android.os.Bundle;
import java.util.Set;

public class Main{

    public static String getStringByCaseInsensitive(Bundle bundle,
            String key) {/*from  w ww. j av a 2  s. com*/
        Set<String> keys = bundle.keySet();
        String lower = key.toLowerCase();
        for (String k : keys) {
            if (k.toLowerCase().equals(lower))
                return bundle.getString(k);
        }

        return null;
    }

}

Related Tutorials