View Single Post
  #2   Spotlight this post!  
Unread 05-07-2012, 22:18
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Preferences check if the element exists

I found the solution to this problem, so I'll post the answer for reference.

Code:
    public static String getSetting(String name) throws NoSettingFound {
        if(Preferences.getInstance().containsKey(name)) {
            return Preferences.getInstance().getString(name, null);
        }else {
            throw new Errs.NoSettingFound(name);
        }
    }
Basically, there is a method meant just for this problem.
__________________
All opinions are my own.
Reply With Quote