get String By Case Insensitive from Bundle - Android Android OS

Android examples for Android OS:Bundle Get

Description

get String By Case Insensitive from Bundle

Demo Code


//package com.book2s;
import java.util.Set;
import android.os.Bundle;

public class Main {
    public static String getStringByCaseInsensitive(Bundle bundle,
            String key) {/*from   w  ww .ja va2  s .  c o m*/
        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