Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRifqi Fahmi
23,164 PointsHow to Store ArrayList of custom object in sharedPreferences ?
Is it possible to save ArrayList of custom object in sharedPreferences ?? Cause i try this http://stackoverflow.com/questions/7057845/save-arraylist-to-sharedpreferences it give me an error when i try to serialize the object. If it possible, how to do that ?
Thanks :D
Javier Mera
16,472 PointsJavier Mera
16,472 PointsI believe you can do this with Gson library. It allows you to create a String from an object or List of Objects, then you'd store that string in SharedPreferences. Then you can retrieve the same String and use Gson methods to convert it back from a String to ArrayList.
Hope that helps