android - Default value on Bundle.getString(String key) -


i've noticed that, while of getters bundle have possibiliy of including default value, in case key doesn't exist in particular bundle instance, getstring not have possibility, returning null if case.

any ideas on why , if there way of easy solution (by easy mean not having check each individual value or extending bundle class).

as example, right have this:

bundle.getstring("item_title"); 

while do:

bundle.getstring("item_title","unknown title"); 

thanks!

you'll have wrap yourself:

public string getbundlestring(bundle b, string key, string def) {     string value = b.getstring(key);     if (value == null)         value = def;     return value; } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -