Created
June 19, 2012 20:33
-
-
Save caseycrites/2956375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public HashSet<String> getSet(String key, HashSet<String> defValue) { | |
| String setString = this.getString(key, null); | |
| if (setString != null) { | |
| try { | |
| JSONArray jsonArray = new JSONArray(setString); | |
| int length = jsonArray.length(); | |
| HashSet<String> set = new HashSet<String>(length); | |
| for (int i = 0; i < length; i++) { | |
| set.add(jsonArray.getString(i)); | |
| } | |
| return set; | |
| } catch (JSONException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| return defValue; | |
| } | |
| public boolean putSet(String key, HashSet<String> value) { | |
| return this.putString(key, new JSONArray(value).toString()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment