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 trial

Android

Diego Marrs
Diego Marrs
8,243 Points

Saving Custom Object Array

Hello.

I was wondering if anyone knew how to save a list of custom objects (with a String getter and setter in my case). A code example would also be very helpful.

Thank you!

Ben Deitch
Ben Deitch
Treehouse Teacher

Hey Diego! What do you mean by String getter and setter? Are you storing Strings?

Diego Marrs
Diego Marrs
8,243 Points

Yeah, the string, in my case, is the name for the object.

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

I think the easiest way would be to concatenate your Strings into one String, and then store/retrieve that one String using SharedPreferences. Here's a good example of this that uses a comma for the delimiter.