Created
July 14, 2015 22:48
-
-
Save luctrudeau/4631eaf4cfe80c29acc4 to your computer and use it in GitHub Desktop.
Android Object Persistence Recipe
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
SharedPreferences settings = getSharedPreferences("ETSPref", 0); | |
List<String> ets = Arrays.asList("I", "Love", "ETS"); | |
// Save Object | |
SharedPreferences.Editor editor = settings.edit(); | |
editor.putString("ILoveETS", new Gson().toJson(ets)); | |
editor.commit(); | |
// Load Object | |
List<String> ets2 = new Gson().fromJson(settings.getString("ILoveETS", ""), List.class); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment